Skip to content

Download deprecated directive definitions and arguments - #10160

Merged
glen-84 merged 2 commits into
mainfrom
gai/introspection-client-directive-deprecation
Jul 28, 2026
Merged

Download deprecated directive definitions and arguments#10160
glen-84 merged 2 commits into
mainfrom
gai/introspection-client-directive-deprecation

Conversation

@glen-84

@glen-84 glen-84 commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • IntrospectionClient / dotnet-graphql silently dropped deprecated directive definitions and deprecated directive arguments from downloaded schemas: the server filters both out unless includeDeprecated: true is passed, and the client never passed it or selected isDeprecated / deprecationReason for directives. @deprecated was also never emitted on a directive definition.
  • A new ServerCapabilities.HasDirectiveDeprecation flag, detected from __Directive.isDeprecated in the existing directive-type probe, gates directives(includeDeprecated: true) plus the deprecation selections, so servers without the field are queried exactly as before. Directive arguments ride on the existing HasArgumentDeprecation, matching how __Type.inputFields is already handled.
  • IntrospectionFormatter now emits @deprecated on directive definitions, and the Directive model carries the deprecation state.

Test plan

  • Formatter test over a new introspection fixture with a deprecated directive definition and a deprecated directive argument, snapshotting the produced SDL.
  • Round-trip against a Hot Chocolate server whose schema contains a deprecated directive with a deprecated argument; both @deprecated applications survive the download.
  • Query-builder snapshot for the new capability, plus the default-capability snapshot proving no includeDeprecated and no isDeprecated are sent when the probe reports the field is absent.

Copilot AI review requested due to automatic review settings July 28, 2026 15:25

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

This PR updates the HotChocolate introspection download/formatting pipeline to correctly include deprecated directive definitions and deprecated directive arguments when the server supports directive deprecation metadata (__Directive.isDeprecated), and to emit @deprecated on directive definitions in the generated SDL.

Changes:

  • Add ServerCapabilities.HasDirectiveDeprecation and detect it via the existing directive-type capability probe.
  • Extend IntrospectionQueryBuilder to request directives(includeDeprecated: true) and select isDeprecated / deprecationReason for directives (gated by capability), and to include deprecated directive arguments when argument deprecation is supported.
  • Extend the introspection model/formatter to carry directive deprecation state and emit @deprecated on directive definitions; add/adjust tests, fixtures, and snapshots.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/IntrospectionQueryBuilderTests.cs Adds a query-builder test covering directive deprecation capability.
src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/IntrospectionFormatterTests.cs Adds a formatter test + inline snapshot for deprecated directive definition + argument output.
src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/IntrospectionClientTests.cs Updates capability assertions to a snapshot and adds a round-trip server test for deprecated directives.
src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/snapshots/IntrospectionQueryBuilderTests.Create_Query_With_DirectiveDeprecation.snap New snapshot verifying directive deprecation selections and includeDeprecated: true.
src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/snapshots/IntrospectionQueryBuilderTests.Create_Query_With_ArgumentDeprecation.snap Updates snapshot to include deprecated directive arguments selection when supported.
src/HotChocolate/Utilities/test/Utilities.Introspection.Tests/resources/IntrospectionWithDeprecatedDirectives.json Adds fixture introspection result containing deprecated directive + deprecated directive argument.
src/HotChocolate/Utilities/src/Utilities.Introspection/ServerCapabilities.cs Adds HasDirectiveDeprecation capability flag.
src/HotChocolate/Utilities/src/Utilities.Introspection/Models/Directive.cs Extends directive model with deprecation fields.
src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionQueryBuilder.cs Updates directives selection set and arguments based on new capability gates.
src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs Emits @deprecated on directive definitions based on introspection data.
src/HotChocolate/Utilities/src/Utilities.Introspection/CapabilityInspector.cs Detects directive deprecation support from __Directive.isDeprecated.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (25/25)

File Covered Changed Patch %
…/Utilities/src/Utilities.Introspection/CapabilityInspector.cs 7 7 100.0% 🟢
…/src/Utilities.Introspection/IntrospectionFormatter.cs 3 3 100.0% 🟢
…/src/Utilities.Introspection/IntrospectionQueryBuilder.cs 12 12 100.0% 🟢
…/Utilities/src/Utilities.Introspection/Models/Directive.cs 2 2 100.0% 🟢
…/Utilities/src/Utilities.Introspection/ServerCapabilities.cs 1 1 100.0% 🟢

Project coverage: 53.9% (232817/431607 lines)

@glen-84
glen-84 merged commit 1536c01 into main Jul 28, 2026
146 checks passed
@glen-84
glen-84 deleted the gai/introspection-client-directive-deprecation branch July 28, 2026 15:51
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