Repository navigation
Fix batch results missing their request and variable indexes - #10718
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
It changes shared execution signatures and the public OperationResult type across server and gateway, and a one-element variable list still lacks its variableIndex.
1 open issue
What changed in this PR
This PR makes batch results carry their correlation indexes. The Fusion gateway now writes requestIndex and variableIndex on batch results, matching Hot Chocolate servers. Request batch items refused before execution, such as ones that fail validation, also carry their requestIndex, so a refused fetch no longer fails every request in the batch. The indexes follow the batching proposal in graphql/graphql-over-http#307.
Changes:
- The gateway passes a variable index through the operation plan execution path and writes it on each result. Request indexes are written on gateway and server results.
OperationResult.RequestIndexgets a backing field and an internal setter. The request executors use it to stamp refused batch items.- New snapshot tests cover request batches, variable batches, and validation failures in the server and gateway test projects. Existing gateway test call sites are updated for the new
variableIndexparameter.
| File | Description |
|---|---|
| OperationPlanContextRoutingTests.cs | Passes variableIndex: -1 to the updated Initialize call. |
| OperationPlanContextResetTests.cs | Passes variableIndex: -1 to the updated Initialize call. |
| OperationPlanContextPoolingTests.cs | Passes variableIndex: -1 in the test helper's Initialize call. |
| ExecutionNodeCompletionTests.cs | Passes variableIndex: -1 to the updated Initialize call. |
| SourceSchemaClientTestBase.cs | Passes variableIndex: -1 to the updated Initialize call. |
| AliasBatchRequestSelectionTests.cs | Passes variableIndex: -1 to the updated Initialize call. |
| VariableBatchingTests.cs | Adds gateway tests for variable batch indexes and a helper that reads them. |
| RequestBatchingTests.cs | New gateway tests for request indexes, including a validation failure. |
| OperationExecutionMiddleware.cs | Sets variableIndex per variable set in batches; the single-set path still passes -1. |
| OperationPlanExecutor.cs | Adds a variableIndex parameter and passes it through to Initialize. |
| OperationPlanContext.Pooling.cs | Stores the variable index when a pooled context is initialized. |
| OperationPlanContext.cs | Adds the variable index field and writes both indexes onto the result. |
| FusionRequestExecutor.cs | Stamps requestIndex on refused request batch items at the gateway. |
| DefaultRequestExecutor.cs | Stamps requestIndex on refused request batch items at the server. |
| OperationResult.cs | Backs RequestIndex with a field and adds an internal setter. |
| HttpPostMiddlewareTests.cs | Adds a server test for requestIndex on a validation failure. |
Review effort: Lite
Contributor
Patch coverage100.0% of changed lines covered (46/46)
Project coverage: 59.5% (317976/534518 lines) |
This was referenced Oct 28, 2026
Open
Merged
This was referenced Nov 2, 2026
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
requestIndexandvariableIndexon batch results, as a Hot Chocolate server does. Before, no gateway batch result carried either index, so a client could not match results to the requests and variable sets of a request batch, whose results arrive in the order they complete.requestIndexon Hot Chocolate servers and gateways alike. A gateway applies a subgraph result without arequestIndexto every request of the batch it sent, so a Hot Chocolate subgraph refusing one fetch of a request batch before execution now fails only that fetch instead of all of them.requestIndexon every result of a request batch, andvariableIndexon every result of a variable batch. A list with one entry, whether the request body orvariables, remains a single request and is answered as a single result.Test plan
HttpPostMiddlewareTests(server) and inRequestBatchingTestsandVariableBatchingTests(gateway) send request batches, variable batches, a request batch holding a variable batch, and a request batch with an item that fails validation, and snapshot the results sorted by their indexes. All five failed before the fix.HotChocolate.AspNetCore.Tests,HotChocolate.Fusion.AspNetCore.Tests,HotChocolate.Fusion.Execution.Tests,HotChocolate.Transport.Http.Tests, andHotChocolate.Diagnostics.Testspass on net10.0.