From 83c450de496035c7d41506862c4f5ad15a3bbc15 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Mon, 2 Sep 2024 09:43:25 +0200 Subject: [PATCH] Allow `@deprecated` directive on arguments and input fields Resolves https://github.com/nuwave/lighthouse/issues/2081 --- CHANGELOG.md | 6 ++++++ docs/6/api-reference/directives.md | 13 ++++++------- docs/master/api-reference/directives.md | 13 ++++++------- src/Schema/Directives/DeprecatedDirective.php | 8 ++++---- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 685e6d0d1e..532ac5b452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ You can find and compare releases at the [GitHub release page](https://github.co ## Unreleased +## v6.44.0 + +### Added + +- Allow `@deprecated` directive on arguments and input fields + ## v6.43.1 ### Changed diff --git a/docs/6/api-reference/directives.md b/docs/6/api-reference/directives.md index 50db50e593..d53a98e6ff 100644 --- a/docs/6/api-reference/directives.md +++ b/docs/6/api-reference/directives.md @@ -1165,17 +1165,16 @@ Marks an element of a GraphQL schema as no longer supported. """ directive @deprecated( """ - Explains why this element was deprecated, usually also including a - suggestion for how to access supported similar data. - Formatted in [Markdown](https://commonmark.org). + Explains why this element was deprecated. + It is also beneficial to suggest what to use instead. + Formatted in Markdown, as specified by [CommonMark](https://commonmark.org). """ reason: String = "No longer supported" -) on FIELD_DEFINITION | ENUM_VALUE +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE ``` -You can mark fields as deprecated by adding the [@deprecated](#deprecated) directive. -It is recommended to provide a `reason` for the deprecation, as well as a suggestion on -how to move forward. +You can indicate schema elements are no longer supported by adding the [@deprecated](#deprecated) directive. +It is recommended to provide a `reason` for the deprecation, as well as suggest a replacement. ```graphql type Query { diff --git a/docs/master/api-reference/directives.md b/docs/master/api-reference/directives.md index 50db50e593..d53a98e6ff 100644 --- a/docs/master/api-reference/directives.md +++ b/docs/master/api-reference/directives.md @@ -1165,17 +1165,16 @@ Marks an element of a GraphQL schema as no longer supported. """ directive @deprecated( """ - Explains why this element was deprecated, usually also including a - suggestion for how to access supported similar data. - Formatted in [Markdown](https://commonmark.org). + Explains why this element was deprecated. + It is also beneficial to suggest what to use instead. + Formatted in Markdown, as specified by [CommonMark](https://commonmark.org). """ reason: String = "No longer supported" -) on FIELD_DEFINITION | ENUM_VALUE +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE ``` -You can mark fields as deprecated by adding the [@deprecated](#deprecated) directive. -It is recommended to provide a `reason` for the deprecation, as well as a suggestion on -how to move forward. +You can indicate schema elements are no longer supported by adding the [@deprecated](#deprecated) directive. +It is recommended to provide a `reason` for the deprecation, as well as suggest a replacement. ```graphql type Query { diff --git a/src/Schema/Directives/DeprecatedDirective.php b/src/Schema/Directives/DeprecatedDirective.php index 8607233caa..76e2fef2d1 100644 --- a/src/Schema/Directives/DeprecatedDirective.php +++ b/src/Schema/Directives/DeprecatedDirective.php @@ -14,12 +14,12 @@ public static function definition(): string """ directive @deprecated( """ - Explains why this element was deprecated, usually also including a - suggestion for how to access supported similar data. Formatted - in [Markdown](https://daringfireball.net/projects/markdown). + Explains why this element was deprecated. + It is also beneficial to suggest what to use instead. + Formatted in Markdown, as specified by [CommonMark](https://commonmark.org). """ reason: String = "No longer supported" -) on FIELD_DEFINITION | ENUM_VALUE +) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE GRAPHQL; } }