Is there an existing issue that is already proposing this?
[X] 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 toregisterEnumTyperegisterEnumType(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' })
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.
Is there an existing issue that is already proposing this?
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 forcreateUnionType
: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.