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

String enums #16

Closed
tony opened this issue Feb 10, 2022 · 4 comments
Closed

String enums #16

tony opened this issue Feb 10, 2022 · 4 comments

Comments

@tony
Copy link

tony commented Feb 10, 2022

It could be valuable in some cases to have string enum output:

export enum Phase {
  SELF_REVIEW = 'SELF_REVIEW',
  PEER_REVIEW = 'PEER_REVIEW',
  MANAGER_REVIEW = 'MANAGER_REVIEW',
  RESULTS = 'RESULTS',
  IDLE = 'IDLE',
}

and possibly a list of string enums:

type PhaseType = keyof typeof Phase

const PhaseTypes: PhaseType[] = [
  SELF_REVIEW,
  PEER_REVIEW,
  MANAGER_REVIEW,
  RESULTS,
  IDLE,
]

^ I haven't tried the above to see if the types themselves connect, but seeing if this in general fits in scope of your project, for the moment

Related

@c0m1t
Copy link
Owner

c0m1t commented Feb 28, 2022

Yes it can be very helpful. I suggest you to take a look at graphql-code-generator. It's a great package which has got tons of options, it can generate enums as you mentioned.

@tony
Copy link
Author

tony commented Feb 28, 2022

@c0m1t Thank you

Knowing that, do you think this should issue should be closed?

Am I potentially suggesting something out of scope for your project, or is string enums something you'd like to add potentially?

@c0m1t
Copy link
Owner

c0m1t commented Feb 28, 2022

As far as I remember, I created this repo because back in the day graphql-code-generator did not have the option to add '%future added value' to the types that were generated from enums. Also we wanted to generate enums once; I think graphql-code-generator used to generate a type for an enum each time it was used in a file. After a while graphql-code-generator added those two options.

I do not have much time to add features to this package, so I cannot promise I will add this feature any time soon. But I greatly appreciate and welcome contributions to this project. So if you like to give it a shot, you can submit a pull request.

@tony
Copy link
Author

tony commented Feb 28, 2022

Noted - similarly at this time, I will first look into graphql-code-generator, which you suggested

I am easy either way as well. I think in the mean time if someone wants to make a PR we can keep this open and it can be reviewed.

If I find that graphql-code-generator doesn't work out I will ping you here.

In the event time passes and this goes stale and you are cleaning up issues, you can close this later on anytime.

@c0m1t c0m1t closed this as completed Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants