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

Generate enums as list #77

Closed
sporto opened this issue Oct 30, 2018 · 2 comments
Closed

Generate enums as list #77

sporto opened this issue Oct 30, 2018 · 2 comments

Comments

@sporto
Copy link
Collaborator

sporto commented Oct 30, 2018

We often use enums as dropdown options e.g.

type Severity
    = Low
    | Medium
    | High

Needs to a list of [Lost, Medium, High] so we can create a dropdown for the user. Elm doesn't allow iterating over union types.

But maybe this lib could fix this. What about if the package also generated enums as a list:

list = [Lost, Medium, High]

In this way if we add a new enum variant in the BE, it will show in the FE dropdown without us having to add it to a list manually.

@dillonkearns
Copy link
Owner

Great idea, thanks for the suggestion! Should be a super easy change, and there's a good payoff. I'll work on this when I get some time 👍

@dillonkearns
Copy link
Owner

Done! This is now released in NPM version 1.0.6. Thanks for the great suggestion!

Here's an example: https://github.com/dillonkearns/elm-graphql/blob/master/examples/src/Swapi/Enum/Episode.elm#L23-L25.

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

No branches or pull requests

2 participants