Repository navigation
Move non-repeatable directive uniqueness to schema validation - #10200
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Moves enforcement of non-repeatable directive uniqueness from the mutable schema parse/merge phase into the central schema validation pipeline, allowing invalid (but representable) schema states to be parsed and then surfaced consistently as validation errors.
Changes:
- Added
DirectiveIsUniqueRule(HCV0031) and wired it intoSchemaValidator, including publishing directive events for the schema definition. - Updated the mutable
SchemaParserextension paths to append directives (instead of throwing) and adjusted parser tests accordingly. - Improved Fusion Federation source parsing by registering an explicit
@linkdirective definition so schema-level applications bind and can be validated/processed consistently.
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| website/content/docs/fusion/source-schema-extensions.md | Updates docs to reflect parser now keeps duplicate non-repeatable directives and relies on validation to fail composition. |
| src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaParserTests.cs | Updates/extends tests to assert duplicates are retained for extension scenarios (field, argument, directive definition). |
| src/HotChocolate/Mutable/src/Types.Mutable/Serialization/SchemaParser.cs | Removes directive merge-time uniqueness throwing and switches extension paths to append directives. |
| src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.resx | Removes the no-longer-used parser error string for duplicate non-repeatable directives. |
| src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.Designer.cs | Removes the generated accessor for the deleted parser resource string. |
| src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaParser.cs | Registers @link for federation sources and keeps @requires registration conditional; supports schema-level directive validation. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/LinkMutableDirectiveDefinition.cs | Adds a minimal mutable directive definition for Apollo Federation @link (schema location, repeatable). |
| src/HotChocolate/Core/test/Types.Validation.Tests/Rules/DirectiveIsUniqueRuleTests.cs | Adds coverage for DirectiveIsUniqueRule across all traversed locations and repeatable/spec cases. |
| src/HotChocolate/Core/src/Types.Validation/SchemaValidator.cs | Adds DirectiveIsUniqueRule to default rules and publishes directive events for the schema definition. |
| src/HotChocolate/Core/src/Types.Validation/Rules/DirectiveIsUniqueRule.cs | Implements the non-repeatable directive uniqueness validation rule. |
| src/HotChocolate/Core/src/Types.Validation/Properties/ValidationResources.resx | Adds the localized message template for the new uniqueness validation error. |
| src/HotChocolate/Core/src/Types.Validation/Properties/ValidationResources.Designer.cs | Adds the generated accessor for the new validation resource string. |
| src/HotChocolate/Core/src/Types.Validation/Logging/LogEntryHelper.cs | Adds DirectiveNotUnique log entry builder and unifies directive member naming for related messages. |
| src/HotChocolate/Core/src/Types.Validation/Logging/LogEntryCodes.cs | Adds HCV0031 code constant for directive uniqueness violations. |
Files not reviewed (2)
- src/HotChocolate/Core/src/Types.Validation/Properties/ValidationResources.Designer.cs: Generated file
- src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.Designer.cs: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Patch coverage98.7% of changed lines covered (74/75)
Uncovered changed lines (JSON){
"sha": "f1f20e92964ab665297e3ec9f272580aa169ce90",
"files": [
{ "path": "src/HotChocolate/Core/src/Types.Validation/Logging/LogEntryHelper.cs", "ranges": [[641, 641]] }
]
}Project coverage: 54.4% (242365/445717 lines) |
This was referenced Aug 16, 2026
This was referenced Aug 25, 2026
Closed
Closed
Closed
Closed
This was referenced Sep 1, 2026
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
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
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
Types.ValidationgainsDirectiveIsUniqueRule(HCV0031), which reports a non-repeatable directive applied more than once at the same location, one entry per directive name however many times it repeats.SchemaParserno longer throws when an extension re-applies a non-repeatable directive.MergeDirectivesis removed and all three extension paths append like every other path, so the invalid state is representable and reported by validation instead of aborting the parse.SchemaValidatorpublishes directive events for the schema definition, soSCHEMA-location applications reach the directive rules. Apollo Federation source schemas apply@linkto the schema without declaring it, so a@linkdefinition is registered for them;RemoveFederationInfrastructurealready strips both the definition and its applications during preprocessing.Test plan
DirectiveIsUniqueRuleTestscovers every location the validator traverses in one case — schema, type, output field, argument, input field, enum value, directive definition, and directive-definition argument — plus a repeatable directive, three applications collapsing to one entry, the type-extension path, and a spec directive.SchemaParserTestsextension cases assert both applications are kept instead of asserting a throw. The argument path had no coverage before.Types.Validation(141),Types.Mutable(88), andFusion.Composition(740), plusTypes.Abstractions,Adapters.OpenApi,Fusion.Utilities, andFusion.Executionas the remaining consumers ofTypes.Validationand the Mutable parser.