Repository navigation
Add opt-in covariant field merging to selection set validation - #10413
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified, and the requested behavior is comprehensively tested.
Review effort: Lite
Findings: None
What changed in this PR
Adds opt-in covariant field merging, allowing fields differing only by nullability to merge during GraphQL validation while preserving existing defaults.
Changes:
- Adds and propagates
EnableCovariantFieldMerging. - Updates merging logic, tests, snapshots, and benchmarks.
- Documents the new schema option.
| File | Summary |
|---|---|
website/content/docs/hotchocolate/server/options.md |
Documents the option. |
src/HotChocolate/Core/test/Validation.Tests/FieldSelectionMergingRuleTests.cs |
Tests merging behavior. |
src/HotChocolate/Core/test/Validation.Tests/DocumentValidatorTests.cs |
Tests validator configuration. |
src/HotChocolate/Core/test/Types.Tests/SchemaOptionsTests.cs |
Tests option copying. |
src/HotChocolate/Core/test/Types.Tests/__snapshots__/SchemaOptionsTests.FromOptions_Should_CopyEveryOption_When_OptionsAreConfigured.snap |
Updates the options snapshot. |
src/HotChocolate/Core/test/Execution.Tests/DependencyInjection/RequestExecutorBuilderExtensions_SchemaOptionsTests.cs |
Tests end-to-end propagation. |
src/HotChocolate/Core/src/Validation/Rules/OverlappingFieldsCanBeMergedRule.cs |
Implements configurable covariant merging. |
src/HotChocolate/Core/src/Validation/Options/ValidationOptions.cs |
Adds validation configuration. |
src/HotChocolate/Core/src/Validation/Extensions/ValidationBuilderExtensions.cs |
Passes the option to the rule. |
src/HotChocolate/Core/src/Types/SchemaOptions.cs |
Adds and copies schema configuration. |
src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs |
Exposes the read-only option. |
src/HotChocolate/Core/src/Types/Execution/RequestExecutorManager.cs |
Propagates schema settings. |
src/HotChocolate/Core/benchmarks/Validation.Benchmarks/OverlappingFieldsMergedBenchmark.cs |
Updates benchmark construction. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Patch coverage100.0% of changed lines covered (32/32)
Project coverage: 58.2% (291020/500394 lines) |
This was referenced Oct 25, 2026
Merged
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
SchemaOptions.EnableCovariantFieldMerging, defaultfalse. When enabled, the field selection merging rule ignores Non-Null wrappers at every level when comparing response shapes, sotitle: Stringon an interface andtitle: String!on an implementing type merge under one response name. List-ness and the named type must still match, and the default behavior is unchanged.ValidationOptionsthe same wayEnableEmptySelectionSetsdoes and can be overridden per validator throughConfigureValidation. The relaxation follows graphql-spec PR 883, proposed for issue 804. Fusion gateway and StrawberryShake support are tracked separately.Test plan
AddDefaultRulesandModifyOptions.SchemaOptionscopy snapshot updated. The Validation test project and the Core solution build pass withEnforceCodeStyleInBuild.