You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the typescript world, it's common to use PascalCase for enum representations.
Typescript
enumCatStatus{HappyAndHealthy,SadAndHealthy}
Code-First approach in the docs suggests using CAPITALIZED_WITH_UNDERSCORES as enum values. But that doesn't play nice with Typescript world.
Describe the solution you'd like
Automatically transform AnyCase, anyCase , any_case to the respective GraphQL enum representation on code generation and map to correct internal representation in NestJS side.
kasvith
changed the title
Automatically transforms enums to CAPITALIZED_WITH_UNDERSCORES style
[discussion]: Automatically transforms enums to CAPITALIZED_WITH_UNDERSCORES style
Nov 3, 2021
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
In GraphQL world, enums are represented as
CAPITALIZED_WITH_UNDERSCORES
. This is described in the GraphQL spec as well.GraphQL
In the typescript world, it's common to use
PascalCase
for enum representations.Typescript
Code-First approach in the docs suggests using
CAPITALIZED_WITH_UNDERSCORES
as enum values. But that doesn't play nice with Typescript world.Describe the solution you'd like
Automatically transform
AnyCase
,anyCase
,any_case
to the respective GraphQL enum representation on code generation and map to correct internal representation in NestJS side.So,
Typescript
Will become
GraphQL
in GraphQL
This will allow us to follow best practices in both worlds.
For example, Elixir Absinthe follows this pattern
Teachability, documentation, adoption, migration strategy
This can be a breaking change, so it can be added as an optional argument to
registerEnumType
What is the motivation / use case for changing the behavior?
Enforcing best practices in both GraphQL and Typescript
The text was updated successfully, but these errors were encountered: