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
enum CatStatus {
HAPPY_AND_HEALTHY
SAD_AND_HEALTHY
}
In the typescript world, it's common to use PascalCase for enum representations.
Typescript
enum CatStatus {
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.
So,
Typescript
enum CatStatus {
happy_AndHealthy,
SadAndHealthy
}
Will become
GraphQL
enum CatStatus {
HAPPY_AND_HEALTHY
SAD_AND_HEALTHY
}
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
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
PascalCasefor enum representations.Typescript
Code-First approach in the docs suggests using
CAPITALIZED_WITH_UNDERSCORESas enum values. But that doesn't play nice with Typescript world.Describe the solution you'd like
Automatically transform
AnyCase,anyCase,any_caseto 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
registerEnumTypeWhat is the motivation / use case for changing the behavior?
Enforcing best practices in both GraphQL and Typescript