Skip to content

Fix deprecation semantics to align with the GraphQL spec - #10193

Merged
michaelstaib merged 5 commits into
mainfrom
mst/deprecation-reason-invariant
Aug 6, 2026
Merged

michaelstaib merged 5 commits into
mainfrom
mst/deprecation-reason-invariant

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings August 4, 2026 08:50

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 HotChocolate’s deprecation handling to align with GraphQL spec semantics by treating “deprecated” as the presence of a (non-empty) deprecation reason, and by standardizing the default @deprecated reason across parsing/serialization/runtime types.

Changes:

  • Standardize default @deprecated reason via DirectiveNames.Deprecated.Arguments.DefaultReason and treat empty/whitespace reasons as “not provided”.
  • Refactor multiple type-system models (Core, Mutable, Fusion, Data) so IsDeprecated is derived from DeprecationReason rather than a separate flag.
  • Add/adjust tests around SDL parsing/printing and deprecation reason normalization.

Reviewed changes

Copilot reviewed 53 out of 53 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/HotChocolate/Utilities/src/Utilities.Introspection/IntrospectionFormatter.cs Use shared default reason and whitespace handling for synthesized @deprecated.
src/HotChocolate/Primitives/src/Primitives/Types/DirectiveNames.cs Change default @deprecated reason constant.
src/HotChocolate/Mutable/test/Types.Mutable.Tests/SchemaParserTests.cs Add parser tests for default deprecation reason and schema printing.
src/HotChocolate/Mutable/test/Types.Mutable.Tests/MutableOutputFieldDefinitionTests.cs New tests for mutable output-field deprecation semantics.
src/HotChocolate/Mutable/test/Types.Mutable.Tests/MutableObjectTypeDefinitionTests.cs Update tests to match new deprecation semantics and whitespace clearing.
src/HotChocolate/Mutable/test/Types.Mutable.Tests/MutableInputFieldDefinitionTests.cs New tests for mutable input-field deprecation semantics.
src/HotChocolate/Mutable/test/Types.Mutable.Tests/MutableEnumValueTests.cs New tests for mutable enum-value deprecation semantics.
src/HotChocolate/Mutable/test/Types.Mutable.Tests/MutableDirectiveDefinitionTests.cs Update tests to match new deprecation semantics and whitespace clearing.
src/HotChocolate/Mutable/src/Types.Mutable/Serialization/SchemaParser.cs Normalize deprecated directive parsing and always supply a default reason when missing/blank.
src/HotChocolate/Mutable/src/Types.Mutable/MutableOutputFieldDefinition.cs Derive IsDeprecated from DeprecationReason; treat whitespace as null.
src/HotChocolate/Mutable/src/Types.Mutable/MutableObjectTypeDefinition.cs Derive IsDeprecated from DeprecationReason; treat whitespace as null.
src/HotChocolate/Mutable/src/Types.Mutable/MutableInputFieldDefinition.cs Derive IsDeprecated from DeprecationReason; treat whitespace as null.
src/HotChocolate/Mutable/src/Types.Mutable/MutableEnumValue.cs Derive IsDeprecated from DeprecationReason; treat whitespace as null.
src/HotChocolate/Mutable/src/Types.Mutable/MutableDirectiveDefinition.cs Derive IsDeprecated from DeprecationReason; treat whitespace as null.
src/HotChocolate/Mutable/src/Types.Mutable/Contracts/IMutableFieldDefinition.cs Remove mutable IsDeprecated setter; document deprecation via DeprecationReason.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Types/FusionSchemaDefinitionDeprecationTests.cs New tests for Fusion schema deprecation defaulting behavior.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Types/FusionEnumValueCollectionTests.cs Update test helpers for changed constructor signature.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Types/FusionDirectiveCollectionTests.cs Update test helpers for changed constructor signature.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionOutputFieldDefinition.cs Derive deprecated flag from normalized DeprecationReason; remove explicit isDeprecated input.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionObjectTypeDefinition.cs Derive IsDeprecated from normalized DeprecationReason; remove explicit isDeprecated input.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionInputFieldDefinition.cs Derive IsDeprecated from normalized DeprecationReason; remove explicit isDeprecated input.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionEnumValue.cs Derive IsDeprecated from normalized DeprecationReason; remove explicit isDeprecated input.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/FusionDirectiveDefinition.cs Derive IsDeprecated from normalized DeprecationReason; adjust obsolete ctor guidance.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Directives/DeprecatedDirectiveParser.cs Parse deprecated reason with validation/defaulting; simplify API to return reason directly.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompositeSchemaContext.cs Update directive creation calls for removed isDeprecated parameters.
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompositeSchemaBuilder.cs Use parsed deprecation reason instead of separate boolean + object.
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaMerger.cs Merge deprecation by propagating first non-null reason (new semantics).
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/EnumScalarRowReuseBenchmark.cs Update benchmark constructors for new deprecation API.
src/HotChocolate/Data/src/Data/Sorting/Fields/SortEnumValue.cs Normalize deprecation via DeprecationReason only.
src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/ObjectTypeDescriptorTests.cs Expand theory coverage for whitespace deprecation reasons.
src/HotChocolate/Core/test/Types.Abstractions.Tests/Serialization/SchemaDebugFormatterTests.cs Remove test relying on deprecated-with-null-reason state.
src/HotChocolate/Core/src/Types/Types/ObjectType.Initialization.cs Normalize deprecation config (whitespace -> null) and derive IsDeprecated.
src/HotChocolate/Core/src/Types/Types/ObjectType.cs Derive IsDeprecated from DeprecationReason.
src/HotChocolate/Core/src/Types/Types/FieldBase.cs Normalize deprecation config (whitespace -> null) and derive IsDeprecated.
src/HotChocolate/Core/src/Types/Types/Factories/SdlToTypeSystemHelper.cs Treat whitespace deprecation reasons as “missing”.
src/HotChocolate/Core/src/Types/Types/DirectiveType.Initialization.cs Normalize deprecation config (whitespace -> null) and derive IsDeprecated.
src/HotChocolate/Core/src/Types/Types/DirectiveType.cs Derive IsDeprecated from DeprecationReason.
src/HotChocolate/Core/src/Types/Types/Descriptors/OutputFieldDescriptorBase.cs Treat whitespace deprecation reason as “no reason provided”.
src/HotChocolate/Core/src/Types/Types/Descriptors/ObjectTypeDescriptor.cs Default whitespace deprecation reason to directive default.
src/HotChocolate/Core/src/Types/Types/Descriptors/EnumValueDescriptor.cs Treat whitespace deprecation reason as “no reason provided”.
src/HotChocolate/Core/src/Types/Types/Descriptors/DirectiveTypeDescriptor.cs Treat whitespace deprecation reason as “no reason provided”.
src/HotChocolate/Core/src/Types/Types/Descriptors/Configurations/FieldConfiguration.cs Treat whitespace deprecation reason as clearing deprecation flag.
src/HotChocolate/Core/src/Types/Types/Descriptors/Configurations/EnumValueConfiguration.cs Compute IsDeprecated from non-whitespace reason.
src/HotChocolate/Core/src/Types/Types/Descriptors/Configurations/DirectiveTypeConfiguration.cs Compute IsDeprecated from non-whitespace reason.
src/HotChocolate/Core/src/Types/Types/Descriptors/ArgumentDescriptorBase~1.cs Treat whitespace deprecation reason as “no reason provided”.
src/HotChocolate/Core/src/Types/Types/DefaultEnumValue.cs Normalize deprecation via DeprecationReason only.
src/HotChocolate/Core/src/Types/Types/Contracts/EnumValue.cs Make IsDeprecated derived from DeprecationReason at contract level.
src/HotChocolate/Core/src/Types.Abstractions/Types/Provider/IDeprecationProvider.cs Define canonical semantics: deprecated iff reason present; add “default reason” helper.
src/HotChocolate/Core/src/Types.Abstractions/Types/IObjectTypeDefinition.cs Remove explicit IsDeprecated override to rely on provider semantics.
src/HotChocolate/Core/src/Types.Abstractions/Types/IDirectiveDefinition.cs Remove explicit IsDeprecated override to rely on provider semantics.
src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaFormatter.cs Require non-null deprecated reason when synthesizing @deprecated.
src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaDebugFormatter.cs Stop defaulting null reasons in debug formatter; rely on new contract.
src/HotChocolate/Core/src/Abstractions/GraphQLDeprecatedAttribute.cs Reject whitespace deprecation reasons at attribute construction time.

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

Comment thread src/HotChocolate/Primitives/src/Primitives/Types/DirectiveNames.cs
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

95.1% of changed lines covered (135/142)

File Covered Changed Patch %
…/Descriptors/Configurations/DirectiveTypeConfiguration.cs 0 1 0.0% 🔴
…/Fusion/src/Fusion.Execution/Execution/Nodes/TypeNameField.cs 0 1 0.0% 🔴
…/src/CodeGeneration/Analyzers/FieldCollector.cs 0 1 0.0% 🔴
…/Core/src/Types.Analyzers/Helpers/CompilationExtensions.cs 1 2 50.0% 🔴
…/src/Types.Abstractions/Serialization/SchemaDebugFormatter.cs 24 27 88.9% 🟡
…/Core/src/Abstractions/GraphQLDeprecatedAttribute.cs 1 1 100.0% 🟢
…/Core/src/Types.Abstractions/Serialization/SchemaFormatter.cs 13 13 100.0% 🟢
…/Types.Abstractions/Types/Provider/IDeprecationProvider.cs 5 5 100.0% 🟢
src/HotChocolate/Core/src/Types/Types/Contracts/EnumValue.cs 1 1 100.0% 🟢
src/HotChocolate/Core/src/Types/Types/DefaultEnumValue.cs 3 3 100.0% 🟢
…/Core/src/Types/Types/Descriptors/ArgumentDescriptorBase~1.cs 1 1 100.0% 🟢
…/Types/Descriptors/Configurations/EnumValueConfiguration.cs 1 1 100.0% 🟢
…/Types/Types/Descriptors/Configurations/FieldConfiguration.cs 1 1 100.0% 🟢
…/Core/src/Types/Types/Descriptors/DirectiveTypeDescriptor.cs 1 1 100.0% 🟢
…/Core/src/Types/Types/Descriptors/EnumValueDescriptor.cs 1 1 100.0% 🟢
…/Core/src/Types/Types/Descriptors/ObjectTypeDescriptor.cs 1 1 100.0% 🟢
…/src/Types/Types/Descriptors/OutputFieldDescriptorBase.cs 1 1 100.0% 🟢
…/Core/src/Types/Types/DirectiveType.Initialization.cs 3 3 100.0% 🟢
src/HotChocolate/Core/src/Types/Types/DirectiveType.cs 1 1 100.0% 🟢
…/Core/src/Types/Types/Factories/SdlToTypeSystemHelper.cs 2 2 100.0% 🟢

+19 more changed files; see the JSON below for uncovered lines.

Uncovered changed lines (JSON)
{
  "sha": "986cc8a2c029a77deaf6e156538ccae74b537e7b",
  "files": [
    { "path": "src/HotChocolate/Core/src/Types/Types/Descriptors/Configurations/DirectiveTypeConfiguration.cs", "ranges": [[60, 60]] },
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/TypeNameField.cs", "ranges": [[49, 49]] },
    { "path": "src/StrawberryShake/CodeGeneration/src/CodeGeneration/Analyzers/FieldCollector.cs", "ranges": [[340, 340]] },
    { "path": "src/HotChocolate/Core/src/Types.Analyzers/Helpers/CompilationExtensions.cs", "ranges": [[169, 169]] },
    { "path": "src/HotChocolate/Core/src/Types.Abstractions/Serialization/SchemaDebugFormatter.cs", "ranges": [[169, 171]] }
  ]
}

Project coverage: 54.4% (242249/445542 lines)

@michaelstaib
michaelstaib merged commit 00c61af into main Aug 6, 2026
1 of 5 checks passed
@michaelstaib
michaelstaib deleted the mst/deprecation-reason-invariant branch August 6, 2026 18:24
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