-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add type reference support to interface builders #2602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add type reference support to interface builders #2602
Conversation
| return this; | ||
| } | ||
|
|
||
| public Builder withInterface(GraphQLInterfaceType interfaceType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shifting this down to be adjacent to the other withInterface method
bbakerman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comments on how to avoid a breaking change
| } | ||
|
|
||
| public Builder replaceInterfaces(List<GraphQLInterfaceType> interfaces) { | ||
| public Builder replaceInterfaces(List<? extends GraphQLNamedOutputType> interfaces) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an API breaking change - albeit a low likelyhood one - but a breaks a break so if we can NOT do it - let not do it.
This can be rewritten like this to avoid the breaking change
public Builder replaceInterfaces(List<GraphQLInterfaceType> interfaces) {
return replaceInterfacesOrReferences(interfaces);
}
public Builder replaceInterfacesOrReferences(List<? extends GraphQLNamedOutputType> interfacesOrReferences) {
and then up above you can change the impl to be
public GraphQLInterfaceType withNewChildren(SchemaElementChildrenContainer newChildren) {
return transform(builder ->
builder.replaceDirectives(newChildren.getChildren(CHILD_DIRECTIVES))
.replaceFields(newChildren.getChildren(CHILD_FIELD_DEFINITIONS))
.replaceInterfacesOrReferences(newChildren.getChildren(CHILD_INTERFACES))
);
}
| return this; | ||
| } | ||
|
|
||
| public Builder withInterfaces(GraphQLTypeReference... references) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add for completeness
Fixes #2546.
An interface (or object) can contain a type reference to itself. The referenced type is replaced with the real type object when the schema is built.
This PR adds support for type references in
GraphQLInterfaceTypebuilders, making these equivalent to builders inGraphQLObjectType.