Skip to content
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

Support const enums for better interoperability with Prisma and other string values #3348

Open
1 task done
danomatic opened this issue Oct 25, 2024 · 0 comments
Open
1 task done
Labels

Comments

@danomatic
Copy link

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

TypeScript enums have known issues:
https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh

This is an example of this with GraphQL types generated by NestJS:
Screenshot 2024-10-25 at 1 03 30 PM

Because if this, if I have a return value from an Prisma enum

Describe the solution you'd like

By default, Prisma generates TS enums as consts, instead of enums. I recommend doing that.

GraphQL Codegen has options to help address this:
https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#constenums
https://the-guild.dev/graphql/codegen/plugins/typescript/typescript#enumsastypes

I propose exposing this and other GraphQL codegen options in the API

Teachability, documentation, adoption, migration strategy

enum consts are backwards compatible, so this shouldn't hurt anything

What is the motivation / use case for changing the behavior?

enum consts just work better all around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant