-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Prohibit root mutation and subscription types from implementing interfaces #1225
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
Open
robrichard
wants to merge
1
commit into
main
Choose a base branch
from
robrichard/root-interfaces
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -144,12 +144,12 @@ type system where those operations begin. | |||||||
| The {`query`} _root operation type_ must be provided and must be an Object type. | ||||||||
|
|
||||||||
| The {`mutation`} _root operation type_ is optional; if it is not provided, the | ||||||||
| service does not support mutations. If it is provided, it must be an Object | ||||||||
| type. | ||||||||
| service does not support mutations. If it is provided, it must be an Object type | ||||||||
| that does not implement interfaces. | ||||||||
|
|
||||||||
| Similarly, the {`subscription`} _root operation type_ is also optional; if it is | ||||||||
| not provided, the service does not support subscriptions. If it is provided, it | ||||||||
| must be an Object type. | ||||||||
| must be an Object type that does not implement interfaces. | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| The {`query`}, {`mutation`}, and {`subscription`} root types must all be | ||||||||
| different types if provided. | ||||||||
|
|
||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
If we were to also restrict the mutation and subscription root type from being a member of a union, I think that validation should go here instead?
https://github.com/graphql/graphql-spec/blob/September2025/spec/Section%203%20--%20Type%20System.md?plain=1#L1452-L1457
Since it would make the union type invalid, not the root type?
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.
I see what you’re saying, but a union won’t know whether something is a root operation type or not. Nothing knows that until the schema itself is constructed, I think?
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.
I think the whole schema has to be constructed in either case? At least in GraphQL-JS we know what the root types are when validating union members.
To translate this to code we'd have to iterate through each type, find all unions and then check each member to see if it's the same as the root type.
Adding it to the union validation we just need to get the root subscription and mutation types from the schema and check against each member.