Skip to content

Derive exported batching flags from the server's batching options - #10368

Merged
glen-84 merged 1 commit into
mainfrom
gai/export-batching-flags-from-server-options
Sep 8, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/export-batching-flags-from-server-options

Conversation

@glen-84

@glen-84 glen-84 commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

  • SchemaFileExporter now writes variableBatching and requestBatching in the generated schema-settings.json from the schema's GraphQLServerOptions.Batching instead of declaring both as true. aliasBatching stays true, since it needs no server support.
  • A source schema that does not call AddSourceSchemaDefaults(), or otherwise allow batching, therefore exports false for both flags, and a gateway composed from that file sends one request per item instead of a variable batch the server rejects with Invalid GraphQL Request. (HC0009).
  • The lookup goes through a small internal ITransportCapabilitiesProvider in Core, implemented in HotChocolate.AspNetCore on top of IOptionsMonitor<GraphQLServerOptions>, so the command-line project keeps its Core-only dependency. Without a registered provider the exporter keeps writing true for both flags.

Test plan

  • New SchemaFileExporterTests cover the fallback without a provider and that provider values are written through to the settings file.
  • New TransportCapabilitiesProviderTests cover no batching, AddSourceSchemaDefaults(), a single allowed flag, and per-schema-name resolution.
  • Existing SchemaExportCommandTests pass with unchanged snapshots.

Copilot AI lite review requested due to automatic review settings September 8, 2026 07:54
@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate labels Sep 8, 2026

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.

🟡 Changes recommended

Re-exporting an existing settings file will not update variableBatching/requestBatching because the current update path only rewrites the top-level name, leaving stale batching flags behind.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates schema export so that the generated *-settings.json accurately reflects which batching modes a subgraph server actually allows, preventing gateways from emitting batching requests a server will reject (e.g., HC0009).

Changes:

  • Derive exported variableBatching / requestBatching from server-side batching configuration via an internal ITransportCapabilitiesProvider (with a default fallback when absent).
  • Add an ASP.NET Core implementation (TransportCapabilitiesProvider) backed by named GraphQLServerOptions and register it in DI.
  • Add new tests for both the exporter behavior and the provider’s mapping logic, plus a small doc update.
File summaries
File Description
website/content/docs/fusion/batching.md Documents that exported batching flags mirror server batching options (except aliasBatching).
src/HotChocolate/Core/test/Types.Tests/Execution/Internal/SchemaFileExporterTests.cs Adds exporter tests for provider fallback and capability passthrough.
src/HotChocolate/Core/src/Types/Execution/Internal/TransportCapabilities.cs Introduces an internal capability model for exporter batching flags.
src/HotChocolate/Core/src/Types/Execution/Internal/ITransportCapabilitiesProvider.cs Adds internal abstraction used by the exporter to obtain capabilities.
src/HotChocolate/Core/src/Types/Execution/Internal/SchemaFileExporter.cs Uses provider-derived capabilities when writing new settings files.
src/HotChocolate/AspNetCore/test/AspNetCore.Tests/TransportCapabilitiesProviderTests.cs Adds mapping tests for server options → transport capabilities (including multi-schema).
src/HotChocolate/AspNetCore/src/AspNetCore/TransportCapabilitiesProvider.cs Implements capability lookup using IOptionsMonitor<GraphQLServerOptions>.
src/HotChocolate/AspNetCore/src/AspNetCore/Extensions/HotChocolateAspNetCoreServiceCollectionExtensions.cs Registers the provider so exports can reflect per-schema server settings.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (26/26)

File Covered Changed Patch %
…/HotChocolateAspNetCoreServiceCollectionExtensions.cs 3 3 100.0% 🟢
…/AspNetCore/src/AspNetCore/TransportCapabilitiesProvider.cs 8 8 100.0% 🟢
…/Core/src/Types/Execution/Internal/SchemaFileExporter.cs 13 13 100.0% 🟢
…/Core/src/Types/Execution/Internal/TransportCapabilities.cs 2 2 100.0% 🟢

Project coverage: 57.9% (288083/497753 lines)

@glen-84
glen-84 merged commit 39e42b0 into main Sep 8, 2026
294 of 296 checks passed
@glen-84
glen-84 deleted the gai/export-batching-flags-from-server-options branch September 8, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants