Skip to content

Can we have utility from tada can return enum object #263

Answered by kitten
tianyingchun asked this question in Q&A
Discussion options

You must be logged in to vote

Don't do this is my suggestion.

This may seem like a great idea at first, however, there are well documented resources on the drawbacks of enums in TypeScript. One could of course reach for const enums, but that explicitly excludes the case you're speaking about.
That's kind of for good reason. Unions of string literals are pretty forward-compatible, but enums are not and give off the impression that you can have exhaustive checks. But in the spirit of GraphQL backwards-compatibility enums are just not a great choice for this.

You can since a recent version replace the types that gql.tada uses for enums using the scalars option, e.g. you can override the type for a given enum type with a …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kitten
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants