Make GraphQLRequestHandler extensible via virtual members - #602
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
Add coverage confirming HandleAsync dispatches through the overridable members.
Pull request overview
This PR makes GraphQLRequestHandler extensible through overridable request-processing members.
Changes:
- Adds virtual introspection, operation execution, and handling steps.
- Exposes
CheckOperationTypeand documents request-body consumption. - Updates type and constructor XML documentation.
File summaries
| File | Summary | Review note |
|---|---|---|
src/FSharp.Data.GraphQL.Server.AspNetCore/GraphQLRequestHandler.fs |
Adds virtual handler extension points and updated documentation. | Moderate: add tests verifying derived-handler overrides are reached. |
Review details
Suppressed comments (1)
src/FSharp.Data.GraphQL.Server.AspNetCore/GraphQLRequestHandler.fs:261
- The new virtual extension points and the
handler.*dispatch are not covered by tests; the existing ASP.NET Core tests only exercise serialization/websocket messages. Please add an xUnit test with a derived handler overriding the execution/dispatch members and assert thatHandleAsyncreaches those overrides, otherwise this central extensibility contract can regress back to closed-over implementations unnoticed.
match! handler.CheckOperationType () with
| IntrospectionQuery optionalAstDocument -> return! handler.ExecuteIntrospectionQuery optionalAstDocument
| OperationQuery content -> return! handler.ExecuteOperation (content)
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
stanislavigertrud
approved these changes
Sep 15, 2026
xperiandri
added a commit
that referenced
this pull request
Sep 15, 2026
The Copilot review on PR #602 asked for coverage that HandleAsync reaches ExecuteIntrospectionQuery/ExecuteOperation/HandleAsync through virtual dispatch rather than closed-over let functions, so the extensibility contract can't silently regress. No test in the repo built an HttpContext or exercised the request handler. Add tests/FSharp.Data.GraphQL.Tests/AspNetCore/RequestHandlerExtensibilityTests.fs: - RecordingHandler overrides ExecuteIntrospectionQuery/ExecuteOperation, records each call, then defers to the base implementation. - SentinelHandler overrides only HandleAsync, to check HandleAsync itself is reached through a GraphQLRequestHandler-typed reference. - createHandler wires a handler through the real AddGraphQL DI registration (ServiceCollection + AddGraphQL + CreateScope), against a DefaultHttpContext with a given method/body, using the existing AspNetCore.TestSchema. It resolves the handler as the base GraphQLRequestHandler<Root> type before calling HandleAsync, so a regression to non-virtual dispatch cannot pass unnoticed. - Four tests cover: GET (introspection, no body), POST introspection query, POST operation query, and the HandleAsync override. Verified the tests actually guard the contract: temporarily bypassed the virtual ExecuteIntrospectionQuery call in HandleAsync (inlining its body directly), which failed the two introspection tests with "Expected: 1, Actual: 0" while leaving the operation and sentinel tests green, then reverted. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
xperiandri
added a commit
that referenced
this pull request
Sep 15, 2026
The Copilot review on PR #602 asked for coverage that HandleAsync reaches ExecuteIntrospectionQuery/ExecuteOperation/HandleAsync through virtual dispatch rather than closed-over let functions, so the extensibility contract can't silently regress. No test in the repo built an HttpContext or exercised the request handler. Add tests/FSharp.Data.GraphQL.Tests/AspNetCore/RequestHandlerExtensibilityTests.fs: - RecordingHandler overrides ExecuteIntrospectionQuery/ExecuteOperation, records each call, then defers to the base implementation. - SentinelHandler overrides only HandleAsync, to check HandleAsync itself is reached through a GraphQLRequestHandler-typed reference. - createHandler wires a handler through the real AddGraphQL DI registration (ServiceCollection + AddGraphQL + CreateScope), against a DefaultHttpContext with a given method/body, using the existing AspNetCore.TestSchema. It resolves the handler as the base GraphQLRequestHandler<Root> type before calling HandleAsync, so a regression to non-virtual dispatch cannot pass unnoticed. - Four tests cover: GET (introspection, no body), POST introspection query, POST operation query, and the HandleAsync override. Verified the tests actually guard the contract: temporarily bypassed the virtual ExecuteIntrospectionQuery call in HandleAsync (inlining its body directly), which failed the two introspection tests with "Expected: 1, Actual: 0" while leaving the operation and sentinel tests green, then reverted. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
xperiandri
force-pushed
the
refactor/graphql-request-handler-extensibility
branch
from
September 15, 2026 17:29
4f7ccf1 to
9c02c9c
Compare
xperiandri
force-pushed
the
refactor/option-to-voption
branch
2 times, most recently
from
September 15, 2026 17:51
8217c3a to
3f5686a
Compare
xperiandri
added a commit
that referenced
this pull request
Sep 15, 2026
The Copilot review on PR #602 asked for coverage that HandleAsync reaches ExecuteIntrospectionQuery/ExecuteOperation/HandleAsync through virtual dispatch rather than closed-over let functions, so the extensibility contract can't silently regress. No test in the repo built an HttpContext or exercised the request handler. Add tests/FSharp.Data.GraphQL.Tests/AspNetCore/RequestHandlerExtensibilityTests.fs: - RecordingHandler overrides ExecuteIntrospectionQuery/ExecuteOperation, records each call, then defers to the base implementation. - SentinelHandler overrides only HandleAsync, to check HandleAsync itself is reached through a GraphQLRequestHandler-typed reference. - createHandler wires a handler through the real AddGraphQL DI registration (ServiceCollection + AddGraphQL + CreateScope), against a DefaultHttpContext with a given method/body, using the existing AspNetCore.TestSchema. It resolves the handler as the base GraphQLRequestHandler<Root> type before calling HandleAsync, so a regression to non-virtual dispatch cannot pass unnoticed. - Four tests cover: GET (introspection, no body), POST introspection query, POST operation query, and the HandleAsync override. Verified the tests actually guard the contract: temporarily bypassed the virtual ExecuteIntrospectionQuery call in HandleAsync (inlining its body directly), which failed the two introspection tests with "Expected: 1, Actual: 0" while leaving the operation and sentinel tests green, then reverted. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
xperiandri
force-pushed
the
refactor/graphql-request-handler-extensibility
branch
from
September 15, 2026 17:51
9c02c9c to
6c9faa5
Compare
Turn the introspection/operation/dispatch steps of GraphQLRequestHandler from private `let`-bound closures into `abstract`/`default` members, so a derived handler can override a single step (e.g. per-request introspection, or custom operation execution) without reimplementing the whole class: - `ExecuteIntrospectionQuery` and `ExecuteOperation` are now virtual, each resolving `options.CurrentValue.SchemaExecutor` itself instead of receiving it as a parameter (dropping the now-pointless generic `<'Root>` from `ExecuteOperation`, which used to shadow the class's own `'Root` without being constrained by it). - `CheckOperationType` becomes a public member (was a private local function), with a `<remarks>` note that it consumes the request body, so calling it more than once on the same request fails to bind on the second call. - `HandleAsync` is now virtual too, and dispatches to the other members through `handler` instead of closing over local functions. Also move the class-level `<summary>` from the primary constructor's doc comment to a `///` line on the type itself, and give the constructor its own "Initializes a new instance..." comment - the constructor comment documented the class, not the constructor. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The Copilot review on PR #602 asked for coverage that HandleAsync reaches ExecuteIntrospectionQuery/ExecuteOperation/HandleAsync through virtual dispatch rather than closed-over let functions, so the extensibility contract can't silently regress. No test in the repo built an HttpContext or exercised the request handler. Add tests/FSharp.Data.GraphQL.Tests/AspNetCore/RequestHandlerExtensibilityTests.fs: - RecordingHandler overrides ExecuteIntrospectionQuery/ExecuteOperation, records each call, then defers to the base implementation. - SentinelHandler overrides only HandleAsync, to check HandleAsync itself is reached through a GraphQLRequestHandler-typed reference. - createHandler wires a handler through the real AddGraphQL DI registration (ServiceCollection + AddGraphQL + CreateScope), against a DefaultHttpContext with a given method/body, using the existing AspNetCore.TestSchema. It resolves the handler as the base GraphQLRequestHandler<Root> type before calling HandleAsync, so a regression to non-virtual dispatch cannot pass unnoticed. - Four tests cover: GET (introspection, no body), POST introspection query, POST operation query, and the HandleAsync override. Verified the tests actually guard the contract: temporarily bypassed the virtual ExecuteIntrospectionQuery call in HandleAsync (inlining its body directly), which failed the two introspection tests with "Expected: 1, Actual: 0" while leaving the operation and sentinel tests green, then reverted. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
xperiandri
force-pushed
the
refactor/graphql-request-handler-extensibility
branch
from
September 15, 2026 18:01
6c9faa5 to
b5cc7d1
Compare
Test Results 9 files 9 suites 11m 10s ⏱️ Results for commit b5cc7d1. |
xperiandri
deleted the
refactor/graphql-request-handler-extensibility
branch
September 15, 2026 18:13
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.
Turn the introspection/operation/dispatch steps of GraphQLRequestHandler from private
let-bound closures intoabstract/defaultmembers, so a derived handler can override a single step (e.g. per-request introspection, or custom operation execution) without reimplementing the whole class:ExecuteIntrospectionQueryandExecuteOperationare now virtual, each resolvingoptions.CurrentValue.SchemaExecutoritself instead of receiving it as a parameter (dropping the now-pointless generic<'Root>fromExecuteOperation, which used to shadow the class's own'Rootwithout being constrained by it).CheckOperationTypebecomes a public member (was a private local function), with a<remarks>note that it consumes the request body, so calling it more than once on the same request fails to bind on the second call.HandleAsyncis now virtual too, and dispatches to the other members throughhandlerinstead of closing over local functions.Also move the class-level
<summary>from the primary constructor's doc comment to a///line on the type itself, and give the constructor its own "Initializes a new instance..." comment - the constructor comment documented the class, not the constructor.