You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The casing was not as I expected: Parts of of the type name (the Smtp) became fully uppercase - in opposite to the GraphQL schema -, and parts of the field name (the "CC" in BCC) became lowercase (and does not comply with the Go naming standard). And a field like Tls, again, would become fully uppercase.
Taken together the behavior is a bit surprising (especially regarding the Smtp) and in case of the field name deviating from the Go standard, but my main issue is that the behavior is contradictory (enforcing a uppercase sequence vs preventing it).
(I know that Smtp deviates from the Go standard as well, but I had to decide elsewhere whether I want to enforce uppercase sequences or disallow them, and with the current gqlgen behavior nothing works out.)
What did you expect?
Ideally the generator would honor my typing. If that's not possible, that it would be nice if the casing would be at least consistent (i.e. let Smtp with those lowercase letters and keep lowercase "CC" in Bcc). Since I generate the GraphQL schema itself as well as the whole service utilizing it elsewhere and the generation itself is quite abstract, it's hard to deal with that unpredictable behavior in the result - neither preventing an uppercase sequence nor enforcing it leads to a reliable outcome.
I think if you want to keep features like "automatic abbreviation detection & uppercasing", they should remain optional mappers one can register or define in the yaml.
I tried to enforce at least the predictable naming for fields via directives like @goField(name: "emailBCC"), but even then the result will look like "emailBcc".
Minimal graphql.schema and models to reproduce
Just take this GraphQL schema and generate the model with gqlgen generate.
typeEmailSmtpInfo {
emailBCC: String
}
versions
gqlgen version? : v0.13.0
go version? : 1.15
dep or go modules? No further dependencies in the go.mod
The text was updated successfully, but these errors were encountered:
JonasDoe
changed the title
Unforeseeable and contradictory naming behavior
Unpredictable and contradictory naming behavior
Nov 3, 2020
What happened?
I generated a
models_gen.go
based on this schema:and got:
The casing was not as I expected: Parts of of the type name (the
Smtp
) became fully uppercase - in opposite to the GraphQL schema -, and parts of the field name (the"CC"
inBCC
) became lowercase (and does not comply with the Go naming standard). And a field likeTls
, again, would become fully uppercase.Taken together the behavior is a bit surprising (especially regarding the
Smtp
) and in case of the field name deviating from the Go standard, but my main issue is that the behavior is contradictory (enforcing a uppercase sequence vs preventing it).(I know that
Smtp
deviates from the Go standard as well, but I had to decide elsewhere whether I want to enforce uppercase sequences or disallow them, and with the currentgqlgen
behavior nothing works out.)What did you expect?
Ideally the generator would honor my typing. If that's not possible, that it would be nice if the casing would be at least consistent (i.e. let
Smtp
with those lowercase letters and keep lowercase"CC"
inBcc
). Since I generate the GraphQL schema itself as well as the whole service utilizing it elsewhere and the generation itself is quite abstract, it's hard to deal with that unpredictable behavior in the result - neither preventing an uppercase sequence nor enforcing it leads to a reliable outcome.I think if you want to keep features like "automatic abbreviation detection & uppercasing", they should remain optional mappers one can register or define in the yaml.
I tried to enforce at least the predictable naming for fields via directives like
@goField(name: "emailBCC")
, but even then the result will look like"emailBcc"
.Minimal graphql.schema and models to reproduce
Just take this GraphQL schema and generate the model with
gqlgen generate
.versions
gqlgen version
? :v0.13.0
go version
? :1.15
go.mod
The text was updated successfully, but these errors were encountered: