Skip to content

Add directives on directive definitions to the Language layer#9904

Merged
glen-84 merged 9 commits into
gai/directives-on-directive-definitionsfrom
gai/lang-directives-on-directive-defs
Jun 12, 2026
Merged

Add directives on directive definitions to the Language layer#9904
glen-84 merged 9 commits into
gai/directives-on-directive-definitionsfrom
gai/lang-directives-on-directive-defs

Conversation

@glen-84

@glen-84 glen-84 commented Jun 12, 2026

Copy link
Copy Markdown
Member

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.

  • DirectiveDefinitionNode gains a Directives collection (parsed between the argument definitions and the repeatable keyword, per the grammar) with constructor, WithDirectives, GetNodes, equality/hashing, and printing support.
  • New DirectiveExtensionNode (SyntaxKind.DirectiveExtension) for extend directive @foo @applied, wired through the parser, printer, visitor, walkers, rewriter, and navigator.
  • New DIRECTIVE_DEFINITION value on the string-based Language.DirectiveLocation.

Test plan

  • Parser tests: directives on definitions (with/without arguments, with repeatable), extend directive parsing, and the grammar's directives-required rule for extensions.
  • Printer round-trip tests (indented + non-indented) and a parse→print→reparse equality test, plus an indented snapshot.
  • Node equality/hashing and GetNodes coverage for both node types; visitor/rewriter/navigator-coordinate coverage for DirectiveExtensionNode.
  • Full HotChocolate.Language suite green: 2703 passed, 0 failed (3 pre-existing skips) on net8.0/9.0/10.0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DirectiveDefinitionNode with a Directives collection 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.

@glen-84 glen-84 merged commit 9fb1540 into gai/directives-on-directive-definitions Jun 12, 2026
4 checks passed
@glen-84 glen-84 deleted the gai/lang-directives-on-directive-defs branch June 12, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants