Skip to content

Enable empty selection sets by default - #10971

Merged
glen-84 merged 7 commits into
mainfrom
gai/empty-selection-sets-by-default
Nov 17, 2026
Merged

glen-84 merged 7 commits into
mainfrom
gai/empty-selection-sets-by-default

Conversation

@glen-84

@glen-84 glen-84 commented Nov 17, 2026

Copy link
Copy Markdown
Member

Summary

Empty selection sets ({ }), which the September 2026 edition of the GraphQL specification allows, are now valid by default in Hot Chocolate and Fusion.

  • EnableEmptySelectionSets on SchemaOptions, ValidationOptions, and FusionOptions defaults to true and is obsolete. Setting it to false still rejects empty selection sets during migration, and the option will be removed in version 17. The Hot Chocolate and Fusion 16.7 to 16.8 migration guides describe the change.
  • subscription { } reports only the specification's single-root-field error. With the option set to false, a composite field with { } reports an empty selection set error instead of the Did you mean "field { ... }"? hint.
  • The syntax printer writes an empty selection set as {}, as Prettier does. Fusion's DocumentRewriter keeps a field or inline fragment whose selections end up empty by selecting __typename, whatever removeStaticallyExcludedSelections is set to, and the planner tests normalize operations the way the gateway does.

Test plan

  • Validation, execution, and Fusion gateway tests cover the new default and the opt-out through ModifyOptions, ConfigureSchema, a prebuilt schema, and ModifyValidationOptions, including persisted documents that skip validation.
  • Printer tests include Prettier 3.10's empty selection set fixtures.
  • Planner and DocumentRewriter tests cover empty fields, inline fragments, mutation fields, and fields whose selections their own condition excludes.
  • The Validation, Execution, Language, Fusion.Execution, PersistedOperations, CostAnalysis, and StrawberryShake code generation test projects pass on net10.0.

Copilot AI lite review requested due to automatic review settings November 17, 2026 14:31
@github-actions github-actions Bot added 📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate labels Nov 17, 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

An active documentation inconsistency remains: the options table does not mention empty fragment selection sets, despite the option also controlling them when validation is disabled.

1 open issue
1 file not reviewed
  • src/HotChocolate/Core/src/Validation/Properties/Resources.Designer.cs: Generated file
What changed in this PR

This pull request enables empty GraphQL selection sets by default across Hot Chocolate and Fusion, aligning validation, execution, printing, and planning with the September 2026 GraphQL specification while retaining an obsolete migration opt-out.

Changes:

  • Default EnableEmptySelectionSets to true across schema, validation, and Fusion options, with migration documentation.
  • Update validation, execution, persisted-operation, cost-analysis, and error-message coverage for enabled and disabled behavior.
  • Serialize empty selection sets as {} and preserve empty Fusion fields and fragments using synthetic __typename selections.
File Description
website/​content/​docs/​hotchocolate/​server/​options.md Documents the new default and obsolete status of EnableEmptySelectionSets.
website/​content/​docs/​hotchocolate/​migrating/​migrate-from-16-7-to-16-8.md Adds Hot Chocolate migration guidance for empty selection sets.
website/​content/​docs/​fusion/​migration/​structure.yaml Adds the Fusion 16.7-to-16.8 migration page to the documentation navigation.
website/​content/​docs/​fusion/​migration/​migrate-from-16-7-to-16-8.md Documents Fusion empty-selection behavior and migration opt-out support.
src/​HotChocolate/​PersistedOperations/​test/​PersistedOperations.InMemory.Tests/​IntegrationTests.cs Covers persisted documents with validation disabled.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​Utilities/​QuerySyntaxPrinterTests.cs Tests printing and round-tripping empty selection sets.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​Utilities/​PrettierParity/​PrettierParityTests.cs Registers empty-selection Prettier parity fixtures.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-6.graphql Adds an unnamed empty subscription formatting fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-6.expected.graphql Defines the expected formatted output for the sixth empty-selection fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-5.graphql Adds a named empty subscription formatting fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-5.expected.graphql Defines the expected formatted output for the fifth empty-selection fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-4.graphql Adds nested empty fields and fragment formatting coverage.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-4.expected.graphql Defines the expected formatted output for the fourth empty-selection fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-3.graphql Adds an empty nested-field formatting fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-3.expected.graphql Defines the expected formatted output for the third empty-selection fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-2.graphql Adds an empty shorthand query formatting fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-2.expected.graphql Defines the expected formatted output for the second empty-selection fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-1.graphql Adds a mixed empty-selection formatting fixture.
src/​HotChocolate/​Language/​test/​Language.SyntaxTree.Tests/​__resources__/​PrettierParity/​selection-set/​empty-1.expected.graphql Defines the expected formatted output for the first empty-selection fixture.
src/​HotChocolate/​Language/​src/​Language.SyntaxTree/​Utilities/​SyntaxSerializer.QuerySyntax.cs Serializes empty selection sets as {}.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Rewriters/​DocumentRewriterTests.cs Tests synthetic __typename selections for empty rewritten fields and fragments.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Planning/​OperationPlannerTests.cs Tests planning operations containing empty composite selections.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​FusionTestBase.cs Aligns planner test normalization with gateway behavior.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Execution/​FusionOptionsTests.cs Updates Fusion option expectations for the new default.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Execution/​EmptySelectionSetTests.cs Covers enabled and disabled Fusion execution paths.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Execution/​__snapshots__/​EmptySelectionSetTests.ExecuteAsync_Should_UseValidationOverrideWithoutSourceRequests_When_EmptySelectionSetsAreEnabled_ValidationOverride.snap Updates the validation override error snapshot.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Execution/​__snapshots__/​EmptySelectionSetTests.ExecuteAsync_Should_MatchSnapshot_When_EmptySelectionSet_EmptySubscription_Enabled.snap Updates empty-subscription execution output.
src/​HotChocolate/​Fusion/​test/​Fusion.Execution.Tests/​Execution/​__snapshots__/​EmptySelectionSetTests.ExecuteAsync_Should_MatchSnapshot_When_EmptySelectionSet_EmptyCompositeField_Disabled.snap Updates the disabled composite-field validation error snapshot.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Rewriters/​DocumentRewriter.Mutation.cs Preserves rewritten mutation fields whose selections become empty.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Rewriters/​DocumentRewriter.cs Retains empty fields and inline fragments using synthetic __typename selections.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Execution/​FusionRequestExecutorManager.cs Propagates the Fusion empty-selection option into document validation.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Execution/​FusionOptions.cs Defaults Fusion empty-selection support to enabled and marks the option obsolete.
src/​HotChocolate/​CostAnalysis/​test/​CostAnalysis.Tests/​CostAnalyzerEmptySelectionSetTests.cs Covers persisted-operation cost analysis with the disabled option.
src/​HotChocolate/​Core/​test/​Validation.Tests/​LeafFieldSelectionsRuleTests.cs Updates selection-rule tests for enabled and disabled empty-selection configurations.
src/​HotChocolate/​Core/​test/​Validation.Tests/​DocumentValidatorTests.cs Tests default acceptance, opt-out rejection, and empty-subscription validation behavior.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​LeafFieldSelectionsRuleTests.InterfaceTypeMissingSelectionEmptySelection.snap Updates the interface composite-field validation snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​LeafFieldSelectionsRuleTests.DirectQueryOnUnionWithoutSubFieldsEmptySelection.snap Updates the union composite-field validation snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​LeafFieldSelectionsRuleTests.DirectQueryOnObjectWithoutSubFieldsEmptySelection.snap Updates the object composite-field validation snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​LeafFieldSelectionsRuleTests.DirectQueryOnInterfaceWithoutSubFieldsEmptySelection.snap Updates the interface composite-field validation snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​DocumentValidatorTests.QueriesWithInvalidVariableTypes.snap Removes obsolete empty-root validation errors from the combined snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​DocumentValidatorTests.EmptySubscription_Should_ReportSingleRootFieldError_WhenOptionsAreDefault.snap Adds the default empty-subscription validation snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​DocumentValidatorTests.EmptySubscription_Should_ReportRootSelectionAndSingleRootFieldErrors.snap Updates the superseded empty-subscription validation snapshot.
src/​HotChocolate/​Core/​test/​Validation.Tests/​__snapshots__/​DocumentValidatorTests.Anonymous_empty_query_repeated_25000.snap Updates validation output for repeated empty operations.
src/​HotChocolate/​Core/​test/​Types.Tests/​__snapshots__/​SchemaOptionsTests.FromOptions_Should_CopyEveryOption_When_OptionsAreConfigured.snap Updates schema option cloning expectations for the new default.
src/​HotChocolate/​Core/​test/​Execution.Tests/​Processing/​__snapshots__/​OperationCompilerTests.Compile_Should_CreateOperationWithEmptySelectionSet_When_RootSelectionSetIsEmpty.snap Updates compiled-operation formatting for empty root selections.
src/​HotChocolate/​Core/​test/​Execution.Tests/​EmptySelectionSetExecutionTests.cs Tests default execution and the obsolete disabled option.
src/​HotChocolate/​Core/​test/​Execution.Tests/​DependencyInjection/​RequestExecutorBuilderExtensions_SchemaOptionsTests.cs Covers schema, validation, prebuilt-schema, and opt-out configuration paths.
src/​HotChocolate/​Core/​test/​Execution.Tests/​__snapshots__/​EmptySelectionSetExecutionTests.Execute_Should_MatchSnapshot_When_EmptySelectionSet_EmptySubscription_Enabled.snap Updates execution output for empty subscriptions.
src/​HotChocolate/​Core/​test/​Execution.Tests/​__snapshots__/​EmptySelectionSetExecutionTests.Execute_Should_MatchSnapshot_When_EmptySelectionSet_EmptyListItems_Disabled.snap Updates disabled list-field validation output.
src/​HotChocolate/​Core/​test/​Execution.Tests/​__snapshots__/​EmptySelectionSetExecutionTests.Execute_Should_MatchSnapshot_When_EmptySelectionSet_EmptyCompositeField_Disabled.snap Updates disabled composite-field validation output.
src/​HotChocolate/​Core/​src/​Validation/​Rules/​LeafFieldSelectionsRule.cs Enables empty selections by default and reports a dedicated opt-out error.
src/​HotChocolate/​Core/​src/​Validation/​Properties/​Resources.resx Adds the empty composite selection-set error message.
src/​HotChocolate/​Core/​src/​Validation/​Properties/​Resources.Designer.cs Adds the generated accessor for the empty-selection validation resource.
src/​HotChocolate/​Core/​src/​Validation/​Options/​ValidationOptions.cs Defaults validation support to enabled and marks the option obsolete.
src/​HotChocolate/​Core/​src/​Validation/​Extensions/​ValidationBuilderExtensions.cs Passes validation options into the leaf-selection rule.
src/​HotChocolate/​Core/​src/​Validation/​ErrorHelper.cs Builds the dedicated empty composite selection-set validation error.
src/​HotChocolate/​Core/​src/​Types/​SchemaOptions.cs Defaults schema support to enabled and preserves option propagation.
src/​HotChocolate/​Core/​src/​Types/​IReadOnlySchemaOptions.cs Updates the read-only option contract and deprecation documentation.
src/​HotChocolate/​Core/​src/​Types/​Execution/​RequestExecutorManager.cs Propagates schema empty-selection settings into document validation.

Review effort: Lite

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

🟢 Approval recommended

No active review issues are identified, and the change includes comprehensive regression coverage across validation, execution, Fusion rewriting, syntax printing, and migration behavior.

No open issues 🎉

1 resolved since last review
1 file not reviewed
  • src/HotChocolate/Core/src/Validation/Properties/Resources.Designer.cs: Generated file

Review effort: Lite

@glen-84
glen-84 merged commit c3faa89 into main Nov 17, 2026
160 checks passed
@glen-84
glen-84 deleted the gai/empty-selection-sets-by-default branch November 17, 2026 15:07
michaelstaib added a commit to michaelstaib/graphql-platform that referenced this pull request Nov 23, 2026
* [Website] Fix HTTP response formatter docs for the v16 API (ChilliCream#10951)

* Fix the release failing while installing k6 for the Fusion PGO profile (ChilliCream#10952)

* Fix the AspNetCore tests failing to build for .NET 8 (ChilliCream#10962)

* Rename the Draft20260903 transport version to September2026 (ChilliCream#10963)

* [Fusion] Match fully reused entities on XxHash3 keys and copy producer rows once (ChilliCream#10941)

* Deprecate the Draft20230127 transport version (ChilliCream#10964)

* [Website] Update benchmark results (ChilliCream#10965)

* Enable empty selection sets by default (ChilliCream#10971)

* Add empty selection set support to StrawberryShake (ChilliCream#10972)

* Persist GitHub CLI login across container rebuilds (ChilliCream#10974)

* Fix the Green Donut documentation link in the README (ChilliCream#10973)

* [Fusion] Fix missing operation plan metadata in YAML test snapshot diffs (ChilliCream#10975)

* Use OIDC for Docker Hub login (ChilliCream#10976)

* [Website] Update benchmark results (ChilliCream#10977)

* Coordinate commercial builds and releases (ChilliCream#10970)

* Parallelize repository preparation in prepare-release.sh (ChilliCream#10978)

* Remove the cloud platform update from the release workflow (ChilliCream#10979)

* [Fusion] Reduce allocations on the error path (ChilliCream#10981)

* [Fusion] Fix missing errors for nested shared value types (ChilliCream#10967)

Co-authored-by: tobias-tengler <45513122+tobias-tengler@users.noreply.github.com>

* [Fusion] Fix null propagation for required list items (ChilliCream#10983)

* [Fusion] Fix lookup error paths (ChilliCream#10986)

* [Fusion] Fix missing errors for null required object list items (ChilliCream#10989)

* [Fusion] Fix late subgraph results dropping siblings of nulled objects (ChilliCream#10990)

* [Fusion] Fix late subgraph results reporting false list length mismatches (ChilliCream#10991)

* [Fusion] Fix results with more than 32,767 source documents throwing (ChilliCream#10998)

* [Website] Update npm dependencies to clear advisories (ChilliCream#11002)

* Update .NET SDK to 11.0.100 (ChilliCream#11004)

* [Fusion] Reduce allocations when forwarding errors (ChilliCream#11003)

* [Nitro CLI] Accept Apollo persisted query manifests for client upload/validate (ChilliCream#11005)

* [Mocha] Fix dispatch race during endpoint startup (ChilliCream#11006)

* [Mocha] Fix ExponentialBackoff returning the same delay once it reaches the maximum (ChilliCream#10870)

* [Mocha] Log receive failures and circuit breaker state changes, and fix the conversation ID of the receive span (ChilliCream#10871)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RequestAsync waiting for a dispatch that outlasts the response timeout (ChilliCream#10872)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Report unhealthy transports in the message bus health check and add a timeout (ChilliCream#10873)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Start reply endpoints first, stop them last, and finish cleanup when a stop is cancelled (ChilliCream#10874)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix the Postgres outbox using up the attempts of a message while the transport is unavailable (ChilliCream#10875)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix scheduled messages using up their attempts while the transport is unavailable (ChilliCream#10876)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Prepare the RabbitMQ transport: internal connection types, RabbitMQ.Client 7.2.2, provisioning with the connection, queue defaults (ChilliCream#10877)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Add the RabbitMQ connection manager and failure classification (ChilliCream#10878)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RabbitMQ consumers not attaching again after a channel or connection loss (ChilliCream#10879)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RabbitMQ sends and publishes completing without the broker's confirmation (ChilliCream#10880)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix messages for a missing RabbitMQ queue or exchange being dropped (ChilliCream#10881)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Fix RabbitMQ requests being sent before the reply consumer is attached (ChilliCream#10882)

Co-authored-by: Pascal Senn <pascal@chillicream.com>

* [Mocha] Move the outbox and scheduler dispatch intervals into their options (ChilliCream#11007)

* Update the .NET 11 packages to the GA release (ChilliCream#11008)

* [Mocha] Fix scalar JSON bodies being cut to their last byte when a stored envelope is read (ChilliCream#11014)

* [Mocha] Fix generated registrations for message types found at publish and send call sites (ChilliCream#11013)

* [Mocha] Fix docs that name APIs and delivery guarantees Mocha does not have (ChilliCream#11015)

* [Mocha] Add UseDispatch, UseReceive and UseConsume to the message bus host builder (ChilliCream#11020)

* Update Aspire and WebUtilities to their patched releases (ChilliCream#11021)

* Set a 7-day NuGet minimum publish age, exempting ChilliCream packages (ChilliCream#11023)

* Replace custom test loggers and clocks with Microsoft testing utilities (ChilliCream#11025)

* [Mocha] Fix saga replies being lost when the sending instance stops (ChilliCream#11022)

* [Fusion] Fix PGO profile handoff to commercial builds (ChilliCream#11027)

* [Fusion] Fix a source schema result staying unreleased when the result callback throws in an alias batch (ChilliCream#11009)

* Fix the fixed-size array pool reserving slots for its largest level up front (ChilliCream#11011)

* Skip unescaping and hashing request documents the parser has seen before (ChilliCream#11010)

* Fix Postgres subscription dispose leaking a connection or hanging (ChilliCream#11026)

* [Mocha] Fix saga replies being discarded when they arrive before the saga state is saved (ChilliCream#11028)

* Snapshot small request feature collections without a frozen dictionary (ChilliCream#10942)

* Fix the cache dropping an entry when a duplicate of its key is evicted (ChilliCream#11039)

* Write the accessed flag of a cache entry only when it is not set (ChilliCream#11040)

* [Fusion] Call Apollo Federation entity lookups without nested async iterators (ChilliCream#11041)

* [Fusion] Read source schema results with the shape that their operation expects (ChilliCream#11043)

* [Website] Add Mocha comparison pages and migration guides (ChilliCream#11024)

* [Fusion] Keep the scratch state of entity lookups per request and build error variable sets on demand (ChilliCream#11042)

* [Fusion] Reference the closed options services of the gateway so Native AOT binaries contain them (ChilliCream#11012)

* [Fusion] Set the operation planner version to 2.13.0

* [Fusion] Update the plan snapshots of the deferred tests to the snapshot format of main

* [Fusion] Fix a sibling field being lost when a late source result has errors below a nulled position

---------

Co-authored-by: Glen <glen.84@gmail.com>
Co-authored-by: Tobias Tengler <45513122+tobias-tengler@users.noreply.github.com>
Co-authored-by: Faris Basha TM <72191505+farisbasha@users.noreply.github.com>
Co-authored-by: vbornand <vbo@netswipe.ch>
Co-authored-by: PascalSenn <senn.pasc@gmail.com>
Co-authored-by: Pascal Senn <pascal@chillicream.com>
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