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

Ability to add directives on extended enum values #952

Open
BoD opened this issue May 30, 2022 · 3 comments
Open

Ability to add directives on extended enum values #952

BoD opened this issue May 30, 2022 · 3 comments

Comments

@BoD
Copy link
Contributor

BoD commented May 30, 2022

This is currently disallowed by the specification:

enum Foo {
  bar
  baz
}

extend enum Foo {
  baz @myDirective
}

From https://spec.graphql.org/draft/#sec-Enum-Extensions.Type-Validation:

  1. All values of an Enum type extension must not already be a value of the original Enum.

Our immediate use-case is that we generate code on the client side and would like to allow renaming certain enum values (in case their name is a reserved keyword, or clashes with other fields in the generated code).

Has this ever come up and would it make sense to allow it?

@benjie
Copy link
Member

benjie commented May 30, 2022

Interesting! You're not attempting to add the enum, but instead to add the directive to it, and there's no way to tell the system that's your intent. I recommend that you add a 10 minute topic to an upcoming GraphQL Working Group to discuss it, e.g.: https://github.com/graphql/graphql-wg/blob/main/agendas/2022/2022-07-07.md

Let me know if you need any guidance, or if you cannot attend WG and would like me to represent it on your behalf.

@mjmahone
Copy link
Contributor

mjmahone commented Jul 7, 2022

This hits on a potentially deeper topic, which is that you sometimes want to merge schema definitions and schema extensions only give us a subset of that merging property (for instance, you can't add an argument to an existing field via schema extensions). The tricky bit is that sometimes you want to merge via a union operation and sometimes via an intersect. Extend implies union, and perhaps we want to just allow deep-unioning for all extensions.

@benjie
Copy link
Member

benjie commented Jul 8, 2022

(From the working group we also noted that it's not possible to add directives to fields in this manner for similar reasons, and a solution to one of these should solve both.)

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