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

Should be able to override enum capitalization #2469

Open
todor-mutafov opened this issue Dec 14, 2022 · 2 comments
Open

Should be able to override enum capitalization #2469

todor-mutafov opened this issue Dec 14, 2022 · 2 comments

Comments

@todor-mutafov
Copy link

Similar to: #1447

What happened?

I'm using gqlgen with enums that look something like this:

enum FilterType {
  CHILDREN
  IDENTITIES
}

enum PhoneType {
  IPHONE
  ANDROID
}

Unfortunately, the go 'enum' constants for these GQL enums are not... ideal...

type FilterType string

const (
	FilterTypeChildren   FilterType = "CHILDREN"
	FilterTypeIDEntities FilterType = "IDENTITIES"
)
type PhoneType string

const (
	PhoneTypeIPHone  PhoneType = "IPHONE"
	PhoneTypeAndroid PhoneType = "ANDROID"
)

What did you expect?

When I say IDENTITIES, I mean the word 'identities', not 'ID Entities'. If I wanted to say 'ID Entities', the schema name would be ID_ENTITIES. The IPHONE example may be more contentious, because I could technically use I_PHONE. But I definitely would like a way to tell gqlgen how to name my enum constants, irrelevant of what abbreviations it thinks it's seeing in the names.

versions

  • go run github.com/99designs/gqlgen version? v0.17.21
  • go version? go version go1.19.2 linux/amd64
@MohitVachhani
Copy link

Can we use a flag based approach here, the person using the api would have power whether commonInitialisms map should be invoked or not!

Like we guys are also facing the same issue!

@nettrino
Copy link

+1 for this issue. Related #1918

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

3 participants