Repository navigation
Answer 405 for unmapped methods on persisted operation routes - #10666
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified, and the supplied assessments unanimously find it ready for approval.
No open issues 🎉
What changed in this PR
This pull request updates persisted-operation routes to return transport-version-appropriate responses for unsupported HTTP methods, aligning them with GraphQL endpoint behavior while preserving CORS preflight handling.
Changes:
- Added fallback handling for unsupported methods, including
404,405, and204 OPTIONSresponses with appropriate headers. - Added ASP.NET Core and Fusion tests for unsupported methods, query negotiation, standalone routes, and CORS.
- Updated HTTP transport, endpoint, and migration documentation.
| File | Summary |
|---|---|
website/content/docs/hotchocolate/server/http-transport.md |
Documents persisted-route status codes and headers. |
website/content/docs/hotchocolate/server/endpoints.md |
Documents unsupported-method behavior for persisted endpoints. |
website/content/docs/hotchocolate/migrating/migrate-from-16-6-to-16-7.md |
Describes the persisted-route behavior change for Hot Chocolate migrations. |
website/content/docs/fusion/migration/migrate-from-16-6-to-16-7.md |
Describes the persisted-route behavior change for Fusion migrations. |
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/PersistedOperationTests.cs |
Tests unsupported methods and OPTIONS on gateway persisted routes. |
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/PersistedOperationMiddlewareTests.cs |
Tests transport-version behavior, allowed methods, QUERY support, standalone routes, and CORS. |
src/HotChocolate/AspNetCore/src/AspNetCore.Pipeline/PersistedOperationMiddleware.cs |
Adds fallback handling for methods not mapped by persisted-operation routes. |
Review effort: Lite
Contributor
Patch coverage100.0% of changed lines covered (21/21)
Project coverage: 59.3% (314820/531228 lines) |
This was referenced Oct 25, 2026
Merged
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.
Summary
MapGraphQLPersistedOperationsmaps answer a method they do not map the way the GraphQL endpoint does. UnderDraft20260903that is 405 withAllow: GET, OPTIONS, POST(plusQUERYwhenEnableQueryRequestsis on) andAccept-Query, or 204 forOPTIONS; under the older transport versions it is 404. The answer no longer depends on whether aMapGraphQLendpoint is mapped above the persisted path, which used to give 404 with the default paths and ASP.NET Core routing's 405 otherwise.MapPersistedOperationMiddlewaresuppresses it (ASP0022 false positive forMapbesideMapGeton the same route pattern dotnet/aspnetcore#69972).MapGraphQL, or at their own path, answer 404 instead of routing's 405 under the older versions.Test plan
PersistedOperationMiddlewareTestscovers PUT, DELETE, HEAD, QUERY while disabled, andOPTIONSon both route patterns across the transport versions,AllowandAccept-Querywith QUERY enabled, persisted routes mapped withoutMapGraphQL, and a CORS preflight that the CORS middleware still answers.PersistedOperationTestscovers PUT andOPTIONSon a gateway that maps only the persisted routes.PersistedOperationMiddlewareTests,PersistedOperationTests,GraphQLOverHttpSpecTests, andHttpQueryMiddlewareTestspass inHotChocolate.AspNetCore.Tests, and the gateway'sPersistedOperationTestsandFusionActivityServerDiagnosticListenerTestspass.HotChocolate.AspNetCore.Pipelinebuilds for net8.0 through net11.0 without warnings.