Restrict root object identification to ROOT_QUERY. #6914
Merged
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.
Although "Mutation" and "Subscription" are technically the default names for the root mutation and subscription types, there should never be any need to refer to those objects, read from them, or write to them, outside the normal process of sending and receiving mutations and subscriptions.
If you think those use cases have any value, #6911 will quickly convince you that the downsides of monopolizing types like
Subscription
andMutation
(e.g. assuming they are always singletons) dramatically outweigh the benefits.In fact, it's not even possible to request the
__typename
field for the rootSubscription
object, according to the GraphQL specification: https://spec.graphql.org/June2018/#sec-Single-root-fieldIn particular, whereas
can be used to find out the
__typename
of the root query object (which might be something other than "Query" in rare situations), the following operation is illegal, because a subscription must have only a single root field:This means the only way to find out that the root
Subscription
type has a__typename
other than "Subscription" would be through an introspection query, which is typically disallowed in production.