Return error instead of panicking on unsupported operation type#1378
Open
LegNeato wants to merge 1 commit into
Open
Return error instead of panicking on unsupported operation type#1378LegNeato wants to merge 1 commit into
LegNeato wants to merge 1 commit into
Conversation
Member
Author
|
CI failures are unrelated and fixed by #1379 |
Executing a `mutation` against a schema built with `EmptyMutation` (or a `subscription` with `EmptySubscription`) panicked with "No mutation type found" / "No subscription type found": the schema reports no root type for that operation (`mutation_type()`/`subscription_type()` return `None`, since `_EmptyMutation`/`_EmptySubscription` are intentionally hidden from the schema), but the executor `.expect()`ed it. Validation does not reject the operation (there is no root type to validate its fields against), so a client-supplied mutation/subscription reached the executor and aborted the request via a panic. Return a new `GraphQLError::NotSupported(OperationType)` request error instead, in both the sync and async query executors and the subscription resolver. This is the spec-aligned behavior (GetOperationRootType raises a request error when the schema has no matching root type). Add regression tests covering sync mutation, async mutation, and subscription against a query-only schema.
0de6151 to
bf1b4e2
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Executing a
mutationagainst a schema withEmptyMutation(or asubscriptionwithEmptySubscription) panics withNo mutation type found/No subscription type foundand aborts the request: the executor.expect()s a root type the schema intentionally doesn't expose, and validation can't reject the operation since there's no root type to check against.Return a new
GraphQLError::NotSupported(OperationType)request error instead, in the sync and async query executors and the subscription resolver. Adds regression tests.