-
Notifications
You must be signed in to change notification settings - Fork 1.1k
allow unions to include interfaces and unions #950
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for graphql-spec-draft ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
❌ Deploy Preview for graphql-spec-draft failed.
|
…ust be explicitly listed within the union
Now implemented in graphql/graphql-js#3682 I added requirement that all subtypes of included abstract types must be explicitly includes within the union. This can always be relaxed later. |
with regard to requirement to list all transitive possible types, including member interfaces
Any news on this? It has been around for 2 years now, and forbidding unions of unions create massive code duplication, possible errors, maintainability headaches, and poor readability. Consider for instance:
|
Complements #939
Addresses #711
Similar to #939, this PR expands the robustness of the type system by allowing types that actually fulfill interfaces to be recognized as such by the GraphQL type system.
Unions
With regard to unions, the goal is to explicitly mark some unions as members of other unions. We have two alternatives:
(A). Let unions include unions as members, as shown above. We could (or could not) require that all members of the unions also be listed (similar to how interfaces implementing child interfaces are required to explicitly list the parent.
Pro:
Con:
(B) Add an additional optional constraint on the union requiring all of the members to be members of some other union, similar to how we have resolved #939.
Potential Syntax:
Interfaces
For interfaces that are members of unions, it would not seem to make sense to require all the implementations of the interfaces to be listed independently. The whole point is that it is often just as useful to indicate that several interfaces might be returned as it is that several individual member types might be returned. For unions, we also have potentially multiple layers of nesting (unions of unions of unions) for which it would be extremely helpful to require the individual member types to be listed (or to use the second syntax above) while we don't have the same issue with interfaces.