Repository navigation
Add enum values merge behavior for Apollo Federation compatibility - #10239
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a configurable enum-value merge policy to better match Apollo Federation composition behavior, particularly allowing output-only enums to diverge across Apollo subgraphs while still enforcing strictness for input-position enums.
Changes:
- Introduces
EnumValuesMergeBehavior(Auto/Strict/Union) and wires it through settings serialization and composer options. - Updates pre-merge validation (
EnumValuesMismatchRule) to allow union merging for output-only enums when Apollo Federation subgraphs are present (or when explicitly configured). - Expands test coverage for the new merge behavior and updates documentation to explain the new semantics.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/content/docs/fusion/connectors/apollofederation.md | Documents Apollo-specific enum value merge behavior and strictness for input-position enums. |
| website/content/docs/fusion/composition.md | Updates ENUM_VALUES_MISMATCH log code guidance to describe Apollo/union behavior and the new setting. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SchemaComposerTests.cs | Adds end-to-end composition tests validating union vs strict enum behavior. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/PreMergeValidationRules/RuleTestBase.cs | Extends test base to allow injecting specific validation rule instances. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/PreMergeValidationRules/EnumValuesMismatchRuleTests.cs | Updates existing tests to construct the rule with EnumValuesMergeBehavior.Auto. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/CompositionSettingsTests.cs | Adds settings serialization/merge tests for EnumValuesMergeBehavior. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/CompositionApiTests.cs | Verifies EnumValuesMergeBehavior is exposed in the public API surface. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/ApolloFederation/ApolloFederationEnumValuesMismatchRuleTests.cs | Adds focused validation tests for Apollo/mixed subgraph scenarios and merge-behavior overrides. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Settings/SettingsJsonSerializerContext.cs | Adds JSON enum converter for EnumValuesMergeBehavior. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Settings/SettingsExtensions.cs | Ensures EnumValuesMergeBehavior participates in settings merge + options materialization. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Settings/CompositionSettings.cs | Adds nullable settings field for EnumValuesMergeBehavior to support legacy config defaults. |
| src/HotChocolate/Fusion/src/Fusion.Composition/SchemaComposer.cs | Validates the enum merge behavior option and passes it into pre-merge rule construction. |
| src/HotChocolate/Fusion/src/Fusion.Composition/PreMergeValidationRules/EnumValuesMismatchRule.cs | Implements the Auto/Strict/Union behavior with output-only enum detection and Apollo presence detection. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Options/SourceSchemaMergerOptions.cs | Adds EnumValuesMergeBehavior option with default Auto. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Options/EnumValuesMergeBehavior.cs | Defines the new enum controlling merge behavior. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryCodes.cs | Adds INVALID_ENUM_VALUES_MERGE_BEHAVIOR log code. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| | [EMPTY_MERGED_UNION_TYPE](https://graphql.github.io/composite-schemas-spec/draft/#sec-Empty-Merged-Union-Type) | The merged union type '\{0\}' is empty. | All members of the union were excluded by `@inaccessible` or tag exclusions. Expose at least one member type, remove the filters that hide them, or remove the union. | | ||
| | [ENUM_TYPE_DEFAULT_VALUE_INACCESSIBLE](https://graphql.github.io/composite-schemas-spec/draft/#sec-Enum-Type-Default-Value-Inaccessible) | The default value of '\{0\}' references the inaccessible enum value '\{1\}'. | A default points to an enum value that is hidden from the composed schema. Either change the default to a value that is accessible or remove `@inaccessible` from the referenced enum value. | | ||
| | [ENUM_VALUES_MISMATCH](https://graphql.github.io/composite-schemas-spec/draft/#sec-Enum-Values-Mismatch) | The enum type '\{0\}' in schema '\{1\}' must define the value '\{2\}'. | An enum is defined in more than one source schema and one of them is missing a value the others declare. Add the missing value to the named source schema so all definitions agree. | | ||
| | [ENUM_VALUES_MISMATCH](https://graphql.github.io/composite-schemas-spec/draft/#sec-Enum-Values-Mismatch) | The enum type '\{0\}' in schema '\{1\}' must define the value '\{2\}'. | An enum is defined in more than one source schema and one of them is missing a value the others declare. Add the missing value to the named source schema so all definitions agree. By default composition is strict per the composite schema spec; when at least one Apollo Federation connector source schema is part of the composition, enums used only in output positions merge their values by union and do not raise this error. The `enumValuesMergeBehavior` merger setting (`auto`, `strict`, `union`) overrides the detection in either direction; enums used in any input position (including through `@key` or `@requires`) always require identical value sets. | |
Comment on lines
+301
to
305
| internal static ImmutableArray<object> CreatePreMergeRules(SchemaComposerOptions options) => | ||
| [ | ||
| new EnumValuesMismatchRule(), | ||
| new EnumValuesMismatchRule(options.Merger.EnumValuesMergeBehavior), | ||
| new ExternalArgumentDefaultMismatchRule(), | ||
| new ExternalArgumentMissingRule(), |
Contributor
Patch coverage79.7% of changed lines covered (110/138)
Uncovered changed lines (JSON){
"sha": "7ab1a4b206b678976d29c77699099e31b9c9656c",
"files": [
{ "path": "src/HotChocolate/Fusion/src/Fusion.Composition/SchemaComposer.cs", "ranges": [[40, 42], [218, 224], [226, 227]] },
{ "path": "src/Nitro/CommandLine/src/CommandLine/Commands/Fusion/FusionSettingsSetCommand.cs", "ranges": [[84, 87]] },
{ "path": "src/Nitro/CommandLine/src/CommandLine/Helpers/EnumValuesMergeBehaviorParser.cs", "ranges": [[22, 23], [25, 25]] },
{ "path": "src/HotChocolate/Fusion/src/Fusion.Composition/PreMergeValidationRules/EnumValuesMismatchRule.cs", "ranges": [[127, 131], [133, 133], [135, 135], [144, 145]] }
]
}Project coverage: 54.5% (243310/446595 lines) |
This was referenced Aug 29, 2026
Merged
This was referenced Sep 8, 2026
Closed
Closed
This was referenced Sep 15, 2026
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#405
Closed
Closed
This was referenced Sep 22, 2026
Closed
Closed
[nuget][SUI_Matcher]- Bump the sui-package-updates group with 20 updates
DFE-Digital/SUI_Matcher#410
Merged
This was referenced Oct 5, 2026
Open
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.
Fixes #10224