Download deprecated directive definitions and arguments - #10160
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.HasDirectiveDeprecationand detect it via the existing directive-type capability probe. - Extend
IntrospectionQueryBuilderto requestdirectives(includeDeprecated: true)and selectisDeprecated/deprecationReasonfor 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
@deprecatedon 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.
Contributor
Patch coverage100.0% of changed lines covered (25/25)
Project coverage: 53.9% (232817/431607 lines) |
This was referenced Aug 9, 2026
Merged
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
IntrospectionClient/dotnet-graphqlsilently dropped deprecated directive definitions and deprecated directive arguments from downloaded schemas: the server filters both out unlessincludeDeprecated: trueis passed, and the client never passed it or selectedisDeprecated/deprecationReasonfor directives.@deprecatedwas also never emitted on a directive definition.ServerCapabilities.HasDirectiveDeprecationflag, detected from__Directive.isDeprecatedin the existing directive-type probe, gatesdirectives(includeDeprecated: true)plus the deprecation selections, so servers without the field are queried exactly as before. Directive arguments ride on the existingHasArgumentDeprecation, matching how__Type.inputFieldsis already handled.IntrospectionFormatternow emits@deprecatedon directive definitions, and theDirectivemodel carries the deprecation state.Test plan
@deprecatedapplications survive the download.includeDeprecatedand noisDeprecatedare sent when the probe reports the field is absent.