-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
I am trying to generate the Golang model for a Graphql fragment like so:
fragment loginMethods on Customer {
loginMethods {
... on PassKeyMethod {
...
... on PasswordMethod {
...
}
... on EmailMethod {
...
}
}
}After running $ go run github.com/Khan/genqlient@main ./genqlient.yaml, I see that there is a clash in the structs that are generated:
func (v *LoginMethods) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*LoginMethods
LoginMethods []json.RawMessage `json:"loginMethods"`. <<<-------- 2 fields in the struct with same name!!
graphql.NoUnmarshalJSON
}
firstPass.LoginMethods = vMy genqlient.yaml is as follows:
# Base template at
# https://github.com/Khan/genqlient/blob/main/docs/genqlient.yaml; refer to the
# template for description of each field.
# Specify where the GrpahQL schema is located.
schema: ./schema.graphql
# Specify the GraphQL operations (queries, mutations, subscriptions) are
# located.
operations:
- ./**/*.graphql
# Specify the filename to which to write the generated code, relative to
# genqlient.yaml. Default: generated.go.
generated: ../../model/android/generated/genqlient.go
# Other config parameters.
use_struct_references: true
optional: pointer_omitempty
bindings:
DateTime:
type: time.Time
Timestamp:
type: time.Time
casing:
# Specify the casing algorithm to use for all GraphQL names (fields, types,
# etc.).
default: auto_camel_case
all_enums: rawTo Reproduce
Generate the Golang code for specified model; unfortunately I cannot share schema.graphql, I can spend some time to handcraft an example schema.graphql if required.
Expected behavior
Struct fields should have unique names, as otherwise this fails compilation.
genqlient version
Latest from master, my go.mod has github.com/Khan/genqlient v0.8.2-0.20251119064104-5b0aabc933fa
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working