-
Notifications
You must be signed in to change notification settings - Fork 396
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
feat(code-first): Use capitalized case for enums in code-first #1852
base: master
Are you sure you want to change the base?
Conversation
@kamilmysliwiec would you please take a look at this |
I added docs in |
e7a18c4
to
7624329
Compare
I've resolved the merge conflict. Also addressed comments by @micalevisk. |
704e47a
to
c2f9576
Compare
I added more test cases |
Hi @kamilmysliwiec would you be able to review this PR and give me a comment about the future of it :) thanks |
This is a subtle but important feature. Agree that by default it should align with GraphQL enum best practices. |
Waiting this PR |
Im ready to resolve conflicts once it gets proper attention |
@kamilmysliwiec would you be able to review this and get the approval i can resolve the merge conflict afterwards |
Hi @kamilmysliwiec any news about this? |
@@ -12,4 +12,5 @@ export interface EnumMetadata<T extends object = any> { | |||
name: string; | |||
description?: string; | |||
valuesMap?: EnumMetadataValuesMap<T>; | |||
mapToUppercase?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kasvith this option seems to be a single purpose one. Would it be better to take a key transform function so that people can use any function they want for the enum keys? toUppercase could then become the default and the feature would become a lot more useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mareksuscak
By convention GraphQL enums are UPPER_CASE literals, i dont see a usecase to have a transformer function and make this much more complicated than it is now
https://www.apollographql.com/tutorials/side-quest-intermediate-schema-design/02-the-enum-type
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #1832
What is the new behavior?
registerEnumType
now contains an optional parameter calledmapToUppercase
(defaults tofalse
to avoid breaking changes). This option automatically converts enum toCONST_CASE
in compliance with GraphQL best practices.It means we can use
PascalCase
intypescript
while usingCONST_CASE
in GraphQL.Would produce the following enum type in schema
Does this PR introduce a breaking change?
Other information
Since this is a norm in GraphQL world, from the next release I consider we should make
mapToUppercase
totrue
by default. So people can use naturalPascalCase
enum values intypescript
and useCONST_CASE
by default inGraphQL