Skip to content

Add enum values merge behavior for Apollo Federation compatibility - #10239

Merged
michaelstaib merged 4 commits into
mainfrom
mst/enum-values-merge-behavior
Aug 15, 2026
Merged

michaelstaib merged 4 commits into
mainfrom
mst/enum-values-merge-behavior

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Aug 15, 2026 •

Copy link
Copy Markdown
Member

Fixes #10224

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

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(),
@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

79.7% of changed lines covered (110/138)

File Covered Changed Patch %
…/HotChocolate/Fusion/src/Fusion.Composition/SchemaComposer.cs 4 16 25.0% 🔴
…/src/CommandLine/Commands/Fusion/FusionSettingsSetCommand.cs 7 11 63.6% 🔴
…/src/CommandLine/Helpers/EnumValuesMergeBehaviorParser.cs 14 17 82.4% 🟡
…/PreMergeValidationRules/EnumValuesMismatchRule.cs 52 61 85.2% 🟡
…/Fusion/src/Fusion.Aspire/AspireCompositionHelper.cs 9 9 100.0% 🟢
…/Fusion/src/Fusion.Aspire/GraphQLCompositionSettings.cs 1 1 100.0% 🟢
…/src/Fusion.Composition/Options/SourceSchemaMergerOptions.cs 1 1 100.0% 🟢
…/src/Fusion.Composition/Settings/CompositionSettings.cs 1 1 100.0% 🟢
…/Fusion/src/Fusion.Composition/Settings/SettingsExtensions.cs 7 7 100.0% 🟢
…/src/CommandLine/Arguments/FusionSettingsNameArgument.cs 1 1 100.0% 🟢
…/src/CommandLine/Commands/Fusion/FusionComposeCommand.cs 7 7 100.0% 🟢
…/src/CommandLine/Options/EnumValuesMergeBehaviorOption.cs 6 6 100.0% 🟢
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)

@michaelstaib
michaelstaib merged commit ead1aa3 into main Aug 15, 2026
6 of 7 checks passed
@michaelstaib
michaelstaib deleted the mst/enum-values-merge-behavior branch August 15, 2026 21:07
This was referenced Aug 29, 2026
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.

Apollo Federation connector rejects Apollo-lawful subgraphs when an output-only enum's values differ across subgraphs (ENUM_VALUES_MISMATCH)

2 participants