Better support for deprecation (and other) directives
Is your feature request related to a problem? Please describe.
While exploring the mesh for composing a public facing gateway composed of multiple sources, one important aspect is the ability to deprecate operations in the mesh to facilitate seamless transitions in the public facing shape. Some sources like the JSON Schema have limited support to add deprecation(no way to specify the reason) on the mesh level, while others like the graphql source requires adding the deprecation on the source itself, which may not necessarily suit all situations. Perhaps a more generic way to add deprecation (and possibly other) directives on a field level would be a better way to solve this?
Describe the solution you'd like
A new transform that could allow adding any custom directive annotations on a field. Perhaps something like
transforms:
- fieldDirective:
- typeName: Foo
fieldName: bar
directive: @deprecated(reason: "lorem ipsum")
Describe alternatives you've considered
If a generic directive transform is undesirable for any reason, a simpler, deprecation-specific transform would also work.
transforms:
- deprecateField:
- typeName: Foo
fieldName: bar
reason: lorem ipsum
Additional context
The JSON Schema field deprecation also breaks if you use something like the hoistField transform to alter the original operation field.
You can use "additionalTypeDefs" to add extra directives.
additionalTypeDefs:
|
extend type Foo {
bar:Bar @deprecated
}
Thank you, @ardatan! One question, though - would this replace any previous directives already in place?
Update: it doesn't seem to work - mesh complains about redefining a field that already exists.
🕸️ Mesh 💥 Error: Field "Foo.bar" already exists in the schema. It cannot also be defined in this type extension.
@modruo If you remove the extend it will work