gqlgen
gqlgen copied to clipboard
False positive for initialism detection "GUID" when generating enum
What happened?
When generating any enum that includes "GUID", it is always detected as an initialism and thus capitalized in the resulting go const. There is a workaround to just write CamelCase enums, but that conflicts with any style guide that uses SHOUTING_SNAKE_CASE for enums, which is what's used in the graphql.org documentation
Evidently "GUID" is a common initialism, but the word "guide" is fairly common.
With the following graphql schema:
enum Resource {
GUIDANCE
TOUR_GUIDE
GUIDE_FEE
GUIDELINES
}
the resulting go code is generated:
const (
ResourceGUIDAnce Resource = "GUIDANCE"
ResourceTourGUIDE Resource = "TOUR_GUIDE"
ResourceGUIDEFee Resource = "GUIDE_FEE"
ResourceGUIDElines Resource = "GUIDELINES"
)
What did you expect?
generated go code:
const (
ResourceGuidance Resource = "GUIDANCE"
ResourceTourGuide Resource = "TOUR_GUIDE"
ResourceGuideFee Resource = "GUIDE_FEE"
ResourceGuidelines Resource = "GUIDELINES"
)
Minimal graphql.schema and models to reproduce
enum Resource {
GUIDANCE
TOUR_GUIDE
GUIDE_FEE
GUIDELINES
}
I don't believe any models or config are relevant.
versions
go run github.com/99designs/gqlgen version? 0.14.0go version? 1.17
Did you try with latest version?
I tried again with 0.17.4 and got the same result.