[typescript] Opt out of suffix for enum value keys
Is your feature request related to a problem? Please describe.
It's a bit odd that suffixes are applied to enum values in addition to the enum itself (when using typesSuffix):
export enum RoleSuffix {
UserSuffix = 'USER',
AdminSuffix = 'ADMIN'
}
Normally the suffix is useful to disambiguate the overall type when importing and using it in files, but there is not much benefit to having a suffix on the values themselves in most cases (UserSuffix, for example).
Describe the solution you'd like
Add a flag to opt out of this behavior. suffixEnumValues true/false
This issue bugs us as well and I can contribute an enhancement for it. I checked the code and it seems that the useTypesPrefix is ignored for enum values.
I see 2 options to implement this and keeping it consistent:
- Just ignore the suffix for enum values. This would be a breaking change.
- Add
suffixEnumValuesandprefixEnumValuesoptions with defaults matching the current behaviour.
Personally, I am fine with both approaches. I would prefer Option 1 if breaking a bit the generated code is OK. I don't think anyone would want to add suffix or prefix to their enum values. And I would lean on simpler configuration until there is an actual need for that.
Which approach do you think makes more sense? /cc @n1ru4l
Following this PR: https://github.com/dotansimha/graphql-code-generator/pull/1553 Maybe, it is really Option 1 that I should go with...