Repository navigation
Add fragment arguments support to the GraphQL syntax layer - #10270
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds experimental support in the HotChocolate GraphQL syntax layer for fragment spread arguments (e.g. ...F(size: 10)), gated behind a new parser option so existing documents remain unaffected by default. It threads the new FragmentSpreadNode.Arguments through parsing, printing/serialization, visitor/rewriter behavior, and syntax equality/hashing, with corresponding test and snapshot updates.
Changes:
- Add
FragmentSpreadNode.Argumentsand update serializer, visitor map, and rewriter to preserve/visit/print arguments. - Introduce experimental parser option
allowFragmentArguments(also implying fragment variables) and update UTF-8 parsers accordingly. - Add/extend unit tests and snapshots to cover parsing, formatting, visiting, rewriting, and round-trip printing of fragment spread arguments.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionQueryBuilder.cs | Updates fragment spread construction to pass an empty arguments list explicitly. |
| src/HotChocolate/Language/test/Language.Web.Tests/snapshots/Utf8GraphQLRequestParserTests.Utf8GraphQLRequestParser_Parse.snap | Snapshot updated to include Arguments: [] on fragment spreads. |
| src/HotChocolate/Language/test/Language.Web.Tests/snapshots/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_With_Cache.snap | Snapshot updated to include Arguments: [] on fragment spreads. |
| src/HotChocolate/Language/test/Language.Web.Tests/snapshots/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_No_Cache.snap | Snapshot updated to include Arguments: [] on fragment spreads. |
| src/HotChocolate/Language/test/Language.Web.Tests/snapshots/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache.snap | Snapshot updated to include Arguments: [] on fragment spreads. |
| src/HotChocolate/Language/test/Language.Web.Tests/snapshots/Utf8GraphQLRequestParserTests.Parse_Id_As_Name.snap | Snapshot updated to include Arguments: [] on fragment spreads. |
| src/HotChocolate/Language/test/Language.Tests/Visitors/SyntaxVisitorTests.cs | Adds visitor tests for fragment spread arguments and fragment definition variable definitions. |
| src/HotChocolate/Language/test/Language.Tests/Visitors/SyntaxRewriterTests.cs | Adds rewriter tests to ensure fragment spread arguments are preserved/rewritten. |
| src/HotChocolate/Language/test/Language.Tests/Utilities/SyntaxPrinterTests.cs | Adds round-trip printing tests for fragment spreads with arguments (and directives). |
| src/HotChocolate/Language/test/Language.Tests/Parser/Utf8SyntaxFormatterTests.cs | Ensures formatting emits fragment variable definitions when fragment arguments are allowed. |
| src/HotChocolate/Language/test/Language.Tests/Parser/QueryParserTests.cs | Adds parser tests for spread arguments and fragment variable definitions under the new flag. |
| src/HotChocolate/Language/test/Language.Tests/Parser/snapshots/KitchenSinkParserTests.ParseFacebookKitchenSinkQuery.snap | Snapshot updated to include Arguments: [] on fragment spreads. |
| src/HotChocolate/Language/test/Language.SyntaxTree.Tests/FragmentSpreadNodeTests.cs | Extends syntax-node tests for equality/hashing and With* preservation of arguments. |
| src/HotChocolate/Language/test/Language.SyntaxTree.Tests/FragmentDefinitionNodeTests.cs | Verifies node enumeration order includes fragment variable definitions. |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.VisitationMap.cs | Adds visitation of fragment spread arguments (gated by VisitArguments) and fragment variable defs. |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxRewriter~1.cs | Ensures rewriter preserves/rewrites FragmentSpreadNode.Arguments. |
| src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Fragments.cs | Extends fragment spread parsing grammar to optionally parse arguments when enabled. |
| src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.cs | Adds _allowFragmentArgs and makes it imply _allowFragmentVars. |
| src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLOperationParser.cs | Makes allowFragmentArguments imply fragment variables in the operation parser options. |
| src/HotChocolate/Language/src/Language.Utf8/ParserOptionsExperimental.cs | Adds AllowFragmentArguments and updates documentation for experimental flags. |
| src/HotChocolate/Language/src/Language.Utf8/ParserOptions.cs | Adds public API surface for allowFragmentArguments via ParserOptions. |
| src/HotChocolate/Language/src/Language.SyntaxTree/Utilities/SyntaxSerializer.QuerySyntax.cs | Prints fragment spread arguments before directives when present. |
| src/HotChocolate/Language/src/Language.SyntaxTree/SyntaxEqualityComparer.cs | Includes fragment spread arguments in syntax equality and hashing. |
| src/HotChocolate/Language/src/Language.SyntaxTree/FragmentSpreadNode.cs | Introduces Arguments on FragmentSpreadNode, updates constructors and With* methods. |
| src/HotChocolate/Language/src/Language.SyntaxTree/FragmentDefinitionNode.cs | Enumerates fragment variable definitions in GetNodes() (mirrors operations). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
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.
Summary
...F(size: 10)) into a newFragmentSpreadNode.Arguments, gated behind the experimentalallowFragmentArgumentsparser option. It is off by default, so existing documents are unaffected.SyntaxRewriter, which would otherwise silently drop them when rebuilding a spread.FragmentDefinitionNodenow also walks its ownVariableDefinitions, mirroringOperationDefinitionNode.FragmentSpreadNodeconstructor as an[Obsolete]overload that delegates with an empty argument list, so this is non-breaking on the 16.x line. EnablingallowFragmentArgumentsimpliesallowFragmentVariablesin bothUtf8GraphQLParserandUtf8GraphQLOperationParser, so one options object means the same thing in both.This is the syntax layer only. Validation rules and the rewrite pass that substitutes arguments into inlined selection sets are follow-ups; no server configuration can reach either execution engine with a fragment-argument document yet, because neither request-parser options type exposes the flag.
Test plan
dotnet test src/HotChocolate/Language/HotChocolate.Language.slnxpasses 4224 tests across net8.0, net9.0, net10.0, and net11.0.Utf8GraphQLOperationParserhonouring the same option asUtf8GraphQLParser.With*call; each was mutation-checked, so removing the production code makes them fail."Arguments": []line. The introspection query builder's printed-GraphQL snapshots are unchanged, confirming its call-site update is behaviour-neutral.