Skip to content

Fix batch results missing their request and variable indexes - #10718

Merged
glen-84 merged 2 commits into
mainfrom
gai/batch-result-indexes
Oct 27, 2026
Merged

glen-84 merged 2 commits into
mainfrom
gai/batch-result-indexes

Conversation

@glen-84

@glen-84 glen-84 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • A Fusion gateway writes requestIndex and variableIndex on 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.
  • A request batch item refused before execution, such as one that fails validation, carries its requestIndex on Hot Chocolate servers and gateways alike. A gateway applies a subgraph result without a requestIndex to 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.
  • Both indexes follow the batching proposal in Adds Batching Proposal graphql/graphql-over-http#307: requestIndex on every result of a request batch, and variableIndex on every result of a variable batch. A list with one entry, whether the request body or variables, remains a single request and is answered as a single result.

Test plan

  • New tests in HttpPostMiddlewareTests (server) and in RequestBatchingTests and VariableBatchingTests (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, and HotChocolate.Diagnostics.Tests pass on net10.0.

Copilot AI lite review requested due to automatic review settings October 27, 2026 14:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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.RequestIndex gets 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 variableIndex parameter.
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

@github-actions

Copy link
Copy Markdown
Contributor

@glen-84
glen-84 merged commit 36b72f8 into main Oct 27, 2026
159 checks passed
@glen-84
glen-84 deleted the gai/batch-result-indexes branch October 27, 2026 15:01
This was referenced Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants