Add directives on directive definitions to the Language layer#9904
Merged
glen-84 merged 9 commits intoJun 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds GraphQL SDL syntax-layer support in HotChocolate.Language for (1) directives applied to directive definitions and (2) extend directive extensions, aligning the AST/parser/printer/visitor pipeline with the updated GraphQL spec draft.
Changes:
- Extended
DirectiveDefinitionNodewith aDirectivescollection and updated parsing/printing/equality/rewriting to include it. - Introduced
DirectiveExtensionNode(SyntaxKind.DirectiveExtension) and wired it through parser, serializer/printer, visitors/walkers/rewriter, and navigator coordinates. - Added/updated unit tests and snapshots to cover parsing and round-tripping of the new syntax.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs | Passes empty directives list when constructing DirectiveDefinitionNode. |
| src/HotChocolate/Language/test/Language.Tests/Visitors/SyntaxVisitorTests.cs | Adds visitor coverage for DirectiveExtensionNode. |
| src/HotChocolate/Language/test/Language.Tests/Visitors/SyntaxRewriterTests.cs | Adds rewrite coverage for directives inside directive extensions. |
| src/HotChocolate/Language/test/Language.Tests/Parser/DirectiveParserTests.cs | Adds parser tests for DIRECTIVE_DEFINITION, directives on directive definitions, and extend directive. |
| src/HotChocolate/Language/test/Language.Tests/Parser/snapshots/KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap | Updates snapshot to include new Directives field on directive definitions. |
| src/HotChocolate/Language/test/Language.SyntaxTree.Tests/Utilities/SchemaSyntaxPrinterTests.cs | Adds printer round-trip and indentation tests for new SDL forms. |
| src/HotChocolate/Language/test/Language.SyntaxTree.Tests/Utilities/snapshots/SchemaSyntaxPrinterTests.Serialize_DirectiveDefWithDirectivesAndExtension_OutHasIndentation.snap | New snapshot for indented printing including directive directives + directive extension. |
| src/HotChocolate/Language/test/Language.SyntaxTree.Tests/DirectiveExtensionNodeTests.cs | New unit tests for DirectiveExtensionNode construction, nodes enumeration, and equality/hashing. |
| src/HotChocolate/Language/test/Language.SyntaxTree.Tests/DirectiveDefinitionNodeTests.cs | Updates existing tests for new ctor arg; adds tests for directive-definition directives. |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker~1.Leave.cs | Adds DirectiveExtension dispatch + virtual hook (generic walker). |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker~1.Enter.cs | Adds DirectiveExtension dispatch + virtual hook (generic walker). |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker.Leave.cs | Adds DirectiveExtension dispatch + virtual hook (non-generic walker). |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxWalker.Enter.cs | Adds DirectiveExtension dispatch + virtual hook (non-generic walker). |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.VisitationMap.cs | Ensures visitor traverses directive-definition directives; adds traversal for directive extensions. |
| src/HotChocolate/Language/src/Language.Visitors/SyntaxRewriter~1.cs | Adds rewrite support for directive-definition directives and directive extensions. |
| src/HotChocolate/Language/src/Language.Visitors/DefaultSyntaxNavigator.cs | Includes directive extensions in schema coordinate creation. |
| src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Extensions.cs | Parses extend directive @name ... as a type system extension. |
| src/HotChocolate/Language/src/Language.Utf8/Utf8GraphQLParser.Directives.cs | Parses directives on directive definitions (between args and repeatable). |
| src/HotChocolate/Language/src/Language.SyntaxTree/Utilities/SyntaxSerializer.SchemaSyntax.cs | Prints directives on directive definitions and prints directive extensions. |
| src/HotChocolate/Language/src/Language.SyntaxTree/Utilities/SyntaxSerializer.cs | Adds serializer dispatch for directive extensions (definition + top-level). |
| src/HotChocolate/Language/src/Language.SyntaxTree/SyntaxKind.cs | Adds SyntaxKind.DirectiveExtension. |
| src/HotChocolate/Language/src/Language.SyntaxTree/SyntaxEqualityComparer.cs | Adds equality/hash support for directive extensions and directive-definition directives. |
| src/HotChocolate/Language/src/Language.SyntaxTree/DirectiveLocation.cs | Adds DIRECTIVE_DEFINITION location constant. |
| src/HotChocolate/Language/src/Language.SyntaxTree/DirectiveExtensionNode.cs | Introduces new AST node for directive extensions. |
| src/HotChocolate/Language/src/Language.SyntaxTree/DirectiveDefinitionNode.cs | Adds Directives collection + API surface updates. |
| src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompositeSchemaContext.cs | Updates directive definition construction to include empty directives list. |
| src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompositeSchemaBuilder.cs | Updates directive definition construction to include empty directives list. |
| src/HotChocolate/Core/src/Types.Abstractions/Serialization/SemanticNonNullSchemaRewriter.cs | Updates directive definition construction to include directives: []. |
| src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaFormatter.cs | Updates directive definition construction to include empty directives list. |
| src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaDebugFormatter.cs | Updates directive definition construction to include empty directives list. |
| dictionary.txt | Adds reparsed to dictionary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9fb1540
into
gai/directives-on-directive-definitions
4 checks passed
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 the
HotChocolate.Language(AST/parser/printer/visitor) support for directives on directive definitions (graphql/graphql-spec#1206, issue #4625), the first of three stacked PRs. Purely additive to the syntax layer; no behavior change for documents that don't use the new syntax.DirectiveDefinitionNodegains aDirectivescollection (parsed between the argument definitions and therepeatablekeyword, per the grammar) with constructor,WithDirectives,GetNodes, equality/hashing, and printing support.DirectiveExtensionNode(SyntaxKind.DirectiveExtension) forextend directive @foo @applied, wired through the parser, printer, visitor, walkers, rewriter, and navigator.DIRECTIVE_DEFINITIONvalue on the string-basedLanguage.DirectiveLocation.Test plan
repeatable),extend directiveparsing, and the grammar's directives-required rule for extensions.GetNodescoverage for both node types; visitor/rewriter/navigator-coordinate coverage forDirectiveExtensionNode.HotChocolate.Languagesuite green: 2703 passed, 0 failed (3 pre-existing skips) on net8.0/9.0/10.0.