Automatically include @deprecated directive where ObsoleteAttribute is used
See original GitHub issueIs your feature request related to a problem? Please describe.
When creating a code-first GraphQL schema, placing an ObsoleteAttribute
on fields for a model/type/query require an explicit call to the IFieldDescriptor.DeprecationReason()
. This can lead to a disconnect between the code I’ve written and the GraphQL model since I need to denote the deprecation in multiple locations.
Describe the solution you’d like
As part of schema generation, it would be great to look for attributes on fields (implicit or explicit) that use the ObsoleteAttribute
and have a valid Message
property value that conforms to the GraphQL spec. This would prevent the need to use both an ObsoleteAttribute
and the DeprecationReason()
method to denote a deprecated field.
Describe alternatives you’ve considered I have not considered additional alternatives at this time.
Additional context This is a feature that is supported by some ASP.NET Core Swagger implementations, and would be nice to include this as part of HotChocolate to provide additional support for code-first schema generation.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:11 (11 by maintainers)
Top GitHub Comments
Closed as of #843
This is closed as of merge #826. One addition I could see being made is a new
GraphQLDeprecatedAttribute(string)
that could be added, similar to theGraphQLDescriptionAttribute
. Would be nice to have both “implicit” support from core attributes, as well as a HotChocolate specific method like descriptions have.