-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
RFC: Allow enums to be remapped like scalars #180
Comments
FWIW, I’m aware we were having this issue, which has been resolved #44 However, it does not address the issue I’m describing here |
This requires explicit codegen for each enum, and doesn't really achieve much. In fact, it introduces more problems that people aren't often aware of in TypeScript.
Basically to put it short:
This is not an explicit goal of the project and there are a lot of “default” options that would need to change in GCG to be more compatible with Related Threads: |
How about the ability to use existing enums, similar to the scalar mapping? I have a fork with the feature as my work needs it to integrate gql.tada in to a legacy codebase - without this the integration is impossible. If this is compatible with the project I can tidy up the code and make a PR. It's a pretty small change. It does require manually mapping every enum, but that's kind of the point as we want to get away from the legacy eventually. |
@sitharus: That's an excellent idea! 💯 I just pushed a PR to implement that, so no worries. I realised that it's a minimal change with |
Summary
It would be great if there was a configuration option to make
gql.tada
emit typescript enums instead of union types for graphql enums.There is a huge difference between these, one of them is that a typescript enum is an object that gets it into the transpiled js code, unlike a union type.
Moreover, this would imrpove compatibility of
tada.gql
with other existing codegen libs, namely@graphql-codegen
. This, in turn, would ease the adoption and migration process for existing projects. In my particular case, the lack of this feature is an actual blocker for migrating my existing projects togql.tada
.Proposed Solution
Let’s say we have a following piece of graphql schema:
Schema interpolation should return something like this:
Whereas currently it returns
Requirements
The text was updated successfully, but these errors were encountered: