-
-
Notifications
You must be signed in to change notification settings - Fork 51
fix(default-value): add flag to utilize generated enum types for default values #636
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
fix(default-value): add flag to utilize generated enum types for default values #636
Conversation
7bcabf9
to
f974993
Compare
Force push resolved a merge conflict with upstream |
ae94242
to
853f91b
Compare
@Code-Hex Any chance we can get this reviewed at your earliest convenience, please and thank you? |
853f91b
to
6eee9eb
Compare
@sutt0n I'm sorry for delay! I check this PR |
6eee9eb
to
7233abf
Compare
@Code-Hex No worries! I see you've updated your |
@Code-Hex The most updated push is the correct one that both builds and passes lint successfully. I had a problem after rebasing from |
4ce0ae4
to
2c7acd4
Compare
@sutt0n Thanks! I will check this morning 🙏 |
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.
@sutt0n If you can fix the areas I commented on and also add valibot support, I'll merge it in!
useEnumTypeAsDefaultValue?: boolean | ||
/** | ||
* @description Uses the full path of the enum type as the default value instead of the stringified value. | ||
* @default { enumValues: "change-case-all#pascalCase" } |
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.
I don't know how to use it with just this, so I think it's better to describe the URL using @link
https://the-guild.dev/graphql/codegen/docs/config-reference/naming-convention
JSDoc: https://jsdoc.app/tags-inline-link
Btw, I think it would be confusing if the user uses transformUnderscore or typeNames as this feature is not applicable. is it possible to support transformUnderscore and typeNames? or write a comment?
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.
@Code-Hex I don't believe that Valibot supports default values for enum/"picklist" types at the moment, it seems like a new library. I don't see anything on the documentation https://valibot.dev/guides/enums/ around enums/"picklists" supporting default values, nor the API for enums: https://valibot.dev/api/enum/
I'll disregard Valibot for now, as it's not possible.
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.
@Code-Hex I've also added a comment for transformUnderscore
and typeNames
.
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.
@Code-Hex I've rebased against main
and this is ready for review now.
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.
@sutt0n Thanks! I agree ignore Valibot for now.
I'm sorry, but could you please add what you added to your comment in the README? I'll merge it once, so if you could make a PR for me, that would be great!
2c7acd4
to
be5a7b7
Compare
fecbe8e
to
ff1296d
Compare
ff1296d
to
c4102fa
Compare
I will merge this PR (#723) instead of this PR to resolve conflict. Please just respond to this correspondence |
The latest of this wonderful plugin has unfortunately broken default values for us and this adds the options,
useEnumTypeAsDefaultValue
to utilize the actual code-generated enum instead of the stringified version and I've exposed thenamingConvention
configuration map -- specifically to targetenumValues
. I'm unsure if others are having this issue as it's very new, and this could very well be an edge-case; furthermore, that's why I've added it behind a flag.Related PR: #529
The Problem
For example, if one were to have the following enum:
We then have the generated schema:
This would throw the following type errors:
Output of Solution
Adding this fix/feature generates this output:
Edit: Addresses #640