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

Add capability to add directive to GraphQL enum and union (Code First approach) #2920

Open
1 task done
AnhQuanTrl opened this issue Jul 14, 2023 · 3 comments
Open
1 task done
Labels

Comments

@AnhQuanTrl
Copy link

AnhQuanTrl commented Jul 14, 2023

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Currently, even though the GraphQL spec allow directive to be added to enum and union. There is no possible solutions at the moment to add them to Enum and Union with the code first approach.

Describe the solution you'd like

For enum, I think we can add a directive options toregisterEnumType
registerEnumType(COLOR, { valuesMap: { RED: { description: 'Risk record', directive: '@directive' }, BLUE: { description: 'Business service record in OpRes', directive: '@directive' }, directive: '@directive' });
The same thing can be done for createUnionType:
createUnionType({ name: 'UnionName', types: ..., directive: '@directive' })

Teachability, documentation, adoption, migration strategy

No response

What is the motivation / use case for changing the behavior?

We need the ability to apply a directive to types and fields in our GraphQL schema and then at build time generate different schema for different environments (parner/third-party and internal use). This is similar to Apollo Contract . Even if we use Apollo Contract, we need a way to apply the @tag directive to enum, enum values and union to hide it.

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this issue?

@AnhQuanTrl
Copy link
Author

I would love to but currently have limited time. I will create a PR once I find some free time. Thank you.

@snovos
Copy link

snovos commented May 31, 2024

Its been a year. Any updates on this?

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

No branches or pull requests

3 participants