Skip to content

Return error instead of panicking on unsupported operation type#1378

Open
LegNeato wants to merge 1 commit into
graphql-rust:masterfrom
LegNeato:fix-empty-mutation-panic
Open

Return error instead of panicking on unsupported operation type#1378
LegNeato wants to merge 1 commit into
graphql-rust:masterfrom
LegNeato:fix-empty-mutation-panic

Conversation

@LegNeato
Copy link
Copy Markdown
Member

@LegNeato LegNeato commented Jun 6, 2026

Executing a mutation against a schema with EmptyMutation (or a subscription with EmptySubscription) panics with No mutation type found / No subscription type found and 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.

@LegNeato
Copy link
Copy Markdown
Member Author

LegNeato commented Jun 6, 2026

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.
@LegNeato LegNeato force-pushed the fix-empty-mutation-panic branch from 0de6151 to bf1b4e2 Compare June 7, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant