Repository navigation
Support constant arguments in field selection maps and @key - #9974
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds composition-layer support for constant arguments on fields referenced by field selection maps (@is, @require, @lookup) and relaxes @key to allow constant arguments, including validation and composition carry-through into generated selection sets.
Changes:
- Introduces constant-argument validation (argument existence, type compatibility, duplicate detection, and required-argument checks) and applies it to field selection maps and
@key. - Preserves constant arguments during field-selection-map → selection-set rewriting so they reach composed directives like
@fusion__requires/@fusion__lookup. - Updates Fusion v16 documentation and expands test coverage for constant-argument behavior and the new
KEY_INVALID_ARGUMENTSerror.
Reviewed changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/docs/fusion/v16/entities-and-lookups.md | Documents constant arguments in @key(fields: ...). |
| website/src/docs/fusion/v16/directives-reference.md | Documents constant arguments for @key, @is, @require; reiterates @provides argument prohibition. |
| website/src/docs/fusion/v16/data-requirements-and-mapping.md | Adds a section explaining constant arguments in selection maps with an example. |
| website/src/docs/fusion/v16/composition.md | Updates composition error table to replace KEY_FIELDS_HAS_ARGUMENTS with KEY_INVALID_ARGUMENTS. |
| src/HotChocolate/Fusion/test/Fusion.Utilities.Tests/Validators/FieldSelectionMapValidatorTests.cs | Adds valid/invalid cases for constant arguments in field selection maps. |
| src/HotChocolate/Fusion/test/Fusion.Utilities.Tests/Validators/ConstantArgumentValidatorTests.cs | New unit tests for constant-argument validation rules. |
| src/HotChocolate/Fusion/test/Fusion.Utilities.Tests/Rewriters/ValueSelectionToSelectionSetRewriterTests.cs | Adds rewrite tests ensuring arguments are preserved in generated selection sets. |
| src/HotChocolate/Fusion/test/Fusion.Utilities.Tests/Converters/FieldSelectionMapValueNodeConverterTests.cs | New unit tests for converting Fusion value nodes to HotChocolate language value nodes. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaValidationRules/KeyInvalidArgumentsRuleTests.cs | New rule tests for KEY_INVALID_ARGUMENTS (unknown arg, incompatible value, missing required, variables). |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaValidationRules/KeyFieldsHasArgumentsRuleTests.cs | Removes tests for the old KEY_FIELDS_HAS_ARGUMENTS rule. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaMerger.OutputField.Tests.cs | Adds snapshot test showing constant arguments preserved in composed @fusion__requires. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/PostMergeValidationRules/RequireInvalidFieldsRuleTests.cs | Adds post-merge validation coverage for constant args in @require selection maps. |
| src/HotChocolate/Fusion/test/Fusion.Composition.Tests/PostMergeValidationRules/IsInvalidFieldsRuleTests.cs | Adds post-merge validation coverage for constant args in @is selection maps. |
| src/HotChocolate/Fusion/src/Fusion.Utilities/Validators/FieldSelectionMapValidator.cs | Hooks constant-argument validation into selection-map validation. |
| src/HotChocolate/Fusion/src/Fusion.Utilities/Validators/ConstantArgumentValidator.cs | New validator implementing constant-argument semantic checks. |
| src/HotChocolate/Fusion/src/Fusion.Utilities/Rewriters/ValueSelectionToSelectionSetRewriter.cs | Preserves arguments when rewriting selections into FieldNodes. |
| src/HotChocolate/Fusion/src/Fusion.Utilities/Properties/FusionUtilitiesResources.resx | Adds localized messages for constant-argument validation errors. |
| src/HotChocolate/Fusion/src/Fusion.Utilities/Properties/FusionUtilitiesResources.Designer.cs | Adds resource accessors for new validator messages. |
| src/HotChocolate/Fusion/src/Fusion.Utilities/Converters/FieldSelectionMapValueNodeConverter.cs | New converter from Fusion language value nodes to HotChocolate language value nodes. |
| src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaValidationRules/KeyInvalidArgumentsRule.cs | New composition rule validating constant arguments in @key(fields: ...). |
| src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaValidationRules/KeyFieldsHasArgumentsRule.cs | Removes old rule that rejected any argument usage in @key fields. |
| src/HotChocolate/Fusion/src/Fusion.Composition/SchemaComposer.cs | Swaps rule registration to use KeyInvalidArgumentsRule. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.resx | Adds log template for KEY_INVALID_ARGUMENTS and removes old template. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs | Updates resource accessors to match resx changes. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryHelper.cs | Adds KeyInvalidArguments(...) log entry builder. |
| src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryCodes.cs | Adds KEY_INVALID_ARGUMENTS code constant and removes KEY_FIELDS_HAS_ARGUMENTS. |
| dictionary.txt | Adds unsupplied to dictionary. |
Files not reviewed (2)
- src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs: Generated file
- src/HotChocolate/Fusion/src/Fusion.Utilities/Properties/FusionUtilitiesResources.Designer.cs: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+71
to
+83
| foreach (var argumentDefinition in field.Arguments.AsEnumerable()) | ||
| { | ||
| if (argumentDefinition.Type.IsNonNullType() | ||
| && argumentDefinition.DefaultValue is null | ||
| && !provided.Contains(argumentDefinition.Name)) | ||
| { | ||
| errors.Add( | ||
| string.Format( | ||
| ConstantArgumentValidator_MissingRequiredArgument, | ||
| argumentDefinition.Name, | ||
| fieldCoordinate)); | ||
| } | ||
| } |
Comment on lines
+201
to
+209
| foreach (var inputField in inputObjectType.Fields.AsEnumerable()) | ||
| { | ||
| if (inputField.Type.IsNonNullType() | ||
| && inputField.DefaultValue is null | ||
| && !provided.Contains(inputField.Name)) | ||
| { | ||
| return false; | ||
| } | ||
| } |
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage in the Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
This was referenced Jun 26, 2026
This was referenced Aug 26, 2026
Closed
This was referenced Sep 7, 2026
This was referenced Sep 17, 2026
This was referenced Sep 28, 2026
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
Adds composition-layer support for constant arguments on selected fields in field selection maps (
@is,@require,@lookup) and relaxes@keyto permit them, per the composite-schemas spec.IS_INVALID_FIELDS/REQUIRE_INVALID_FIELDSand the renamedKEY_INVALID_ARGUMENTS(wasKEY_FIELDS_HAS_ARGUMENTS).@fusion__requires/@fusion__lookup.@providescontinues to disallow arguments.Test plan
dotnet test src/HotChocolate/Fusion/test/Fusion.Utilities.Tests— 238 passdotnet test src/HotChocolate/Fusion/test/Fusion.Composition.Tests— 525 pass@is,@require, and@key, the value-node converter, the rewriter carry-through, and a composition snapshot showing constant arguments in@fusion__requires.