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

Better support for deprecation (and other) directives #7468

Open
modruo opened this issue Aug 6, 2024 · 4 comments
Open

Better support for deprecation (and other) directives #7468

modruo opened this issue Aug 6, 2024 · 4 comments

Comments

@modruo
Copy link

modruo commented Aug 6, 2024

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.

@ardatan
Copy link
Owner

ardatan commented Aug 6, 2024

You can use "additionalTypeDefs" to add extra directives.

additionalTypeDefs:
      |
        extend type Foo {
             bar:Bar @deprecated
        }

@modruo
Copy link
Author

modruo commented Aug 6, 2024

Thank you, @ardatan! One question, though - would this replace any previous directives already in place?

@modruo
Copy link
Author

modruo commented Aug 6, 2024

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.  

@paales
Copy link

paales commented Nov 18, 2024

@modruo If you remove the extend it will work

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

No branches or pull requests

3 participants