Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend support for @deprecated directive #2081

Closed
wimski opened this issue Mar 9, 2022 · 5 comments · Fixed by #2607
Closed

Extend support for @deprecated directive #2081

wimski opened this issue Mar 9, 2022 · 5 comments · Fixed by #2607
Labels
enhancement A feature or improvement

Comments

@wimski
Copy link
Contributor

wimski commented Mar 9, 2022

The @deprecated directive currently is only allowed on FIELD_DEFINITION and ENUM_VALUE:

"""
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://daringfireball.net/projects/markdown/).
  """
  reason: String = "No longer supported"
) on FIELD_DEFINITION | ENUM_VALUE

However any schema element could become deprecated at some point, like an obsolete/unused input field for example. Would it be possible to add the following to the supported types of the @deprecated directive?

  • ARGUMENT_DEFINITION
  • INPUT_FIELD_DEFINITION
@spawnia
Copy link
Collaborator

spawnia commented Mar 9, 2022

Looks like this will be possible in an upcoming version of the GraphQL specification - see graphql/graphql-spec#805 (comment)

We have to implement this in the base library first though, see webonyx/graphql-php#110

@spawnia spawnia added the enhancement A feature or improvement label Mar 9, 2022
@spawnia spawnia changed the title Extend support for @deprecated directive Extend support for @deprecated directive Jul 17, 2024
@owenvoke
Copy link
Contributor

owenvoke commented Sep 2, 2024

@spawnia, is this now ok to implement for Lighthouse? 👀

@spawnia
Copy link
Collaborator

spawnia commented Sep 2, 2024

It is already possible to use @deprecated as described, given https://github.com/webonyx/graphql-php/releases/tag/v15.4.0 is installed. I updated our definition of the directive in #2607.

@spawnia
Copy link
Collaborator

spawnia commented Sep 2, 2024

Released the updated definition with https://github.com/nuwave/lighthouse/releases/tag/v6.44.0.

@owenvoke
Copy link
Contributor

owenvoke commented Sep 2, 2024

@spawnia, interestingly, when dumping the schema with php artisan lighthouse:print-schema, it strips the @deprecated tag from the output for both of these. When looking into it, it seems like the deprecationReason property never gets added for arguments.

I've opened #2609 to fix the issue, but please let me know if I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants