Support extending fields in Mutable SchemaParser#9620
Conversation
Allow object and interface type extensions to redeclare an existing field to add directives or new arguments, per graphql-spec PR #1196. The description on an extension field/argument may be omitted, but must match the original exactly when provided.
There was a problem hiding this comment.
Pull request overview
This PR extends the Mutable SchemaParser to support “field extension” semantics for object and interface type extensions, allowing extensions to redeclare existing fields/arguments to add directives and/or additional arguments while validating that core definition aspects don’t change.
Changes:
- Reordered parse phases so directive definitions are built before applying type extensions (to correctly respect repeatability when merging directives).
- Added field/argument extension logic that merges directives and arguments, while rejecting type/description/default-value mismatches and duplicate names within an extension.
- Added comprehensive unit tests covering field/argument extension behavior, directive repeatability rules, and mismatch error cases.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaParserTests.cs |
Adds tests for extending existing fields/arguments via SDL extensions and validates error conditions. |
src/HotChocolate/Mutable/src/Types.Mutable/Serialization/SchemaParser.cs |
Implements field/argument extension logic (merge directives/args) and reorders parsing steps for correct directive repeatability handling. |
src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.resx |
Adds new localized error message templates for extension mismatch scenarios and non-repeatable directive reapplication. |
src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.Designer.cs |
Updates generated resource accessors for the new error messages. |
Files not reviewed (1)
- src/HotChocolate/Mutable/src/Types.Mutable/Properties/MutableResources.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9620 +/- ##
==========================================
- Coverage 74.16% 0 -74.17%
==========================================
Files 2677 0 -2677
Lines 140790 0 -140790
Branches 16371 0 -16371
==========================================
- Hits 104421 0 -104421
+ Misses 30774 0 -30774
+ Partials 5595 0 -5595
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
graphql/graphql-spec#1196