gqlgen
gqlgen copied to clipboard
Schema naming collision causes compilation error
What happened?
Expanding on https://github.com/99designs/gqlgen/discussions/2040#discussion-3929370
This is an ongoing issue if you have two fields with different casing within the same type. They're not clashing per GraphQL spec, however - when generated into a struct, the names are exactly the same and it causes a compilation issue.
type MyQuery {
field_name: String
fieldName: String
}
type MyQueryValue struct {
FieldName *bool `json:"field_name,omitempty"`
FieldName *bool `json:"fieldName,omitempty"`
}
What did you expect?
I'd expect that there's a way to handle this similar to how the documentation suggests enum name collision is dealt with. https://gqlgen.com/reference/name-collision
type MyQuery {
field_name: String
fieldName: String
}
type MyQueryValue struct {
FieldName *bool `json:"field_name,omitempty"`
FieldName0 *bool `json:"fieldName,omitempty"`
}
Minimal graphql.schema and models to reproduce
See above
versions
-
go run github.com/99designs/gqlgen version
? - v0.17.36 -
go version
? - go version go1.20.5 darwin/arm64