-
Notifications
You must be signed in to change notification settings - Fork 1.2k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Enum with int values #366
Comments
Good idea! Like |
This is probably a good use-case for |
The other option would be custom mapping - you'd be opting out of model generation, but you could map the enum however you like |
@lwc How the directive function looks like?
|
Another vote for numeric enums type ItemStatus int
const (
Waiting ItemStatus = iota
Filled
BackOrdered
OrderExceeded
NotOrdered
)
func (s ItemStatus) String() string {
switch s {
case Waiting:
return "Waiting"
case Filled:
return "Filled"
case BackOrdered:
return "Back Ordered"
case OrderExceeded:
return "Order Exceeded"
case NotOrdered:
return "Not Ordered"
default:
return fmt.Sprintf("%d", int(s))
}
} |
It would also be great for a simple permission system, so I could check for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@vektah Could you please reopen this issue. Thanks |
@karthikraobr thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
No stale |
Right now I'm using this fork of enumer which adds GQLGen support via this PR. It may help people :) |
Is there any progress on this? I'm guessing the above solution won't be merged cause it's solution that adds hacky code which only provides int enums instead of abstacting type support. My current work around for people wanting to this (doesnt fully auto-generate) schema.graphqls
run add to YOUR_MODEL_FILE.go
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Is it possible to generate enum with int values rather than string values? Something that looks like the below code?
Minimal graphql.schema and models to reproduce
Generates
Is there any way to generate int values rather than string values for enums? Perhaps a custom resolver?
The text was updated successfully, but these errors were encountered: