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
In a system with: 1 type (CompactPost) and 2 interfaces (PostInterface1, PostInterface2), when requesting different selections sets from the types/interfaces, the output differs depending on which selection set requests all fields or fewer fields.
Run the BadQuery.graphql or GoodQuery.graphql to see the differences in output
Place a breakpoint in 99designs/[email protected]/graphql/handler/transport/util.go in writeJson to see the output before it is written. It has duplicate keys for awards before the response is written. After the response is written it takes the last of those duplicate keys.
Expected behavior
Expect the output to be a deep merge of the selection sets into a single response list, rather than allowing the JSON writer to select the last of the duplicate keys.
The working query
# This query fetches posts and their associated awards.
# It includes inline fragments to handle different post types/interfaces
# It only works because it requests the same fields in all fragments for awards
query GoodQuery {
posts {
__typename
awards {
__typename
id
name
}
... on CompactPost {
__typename
id
awards {
__typename
id
name
}
}
... on PostInterface2 {
__typename
id
awards {
__typename
name
id
}
}
}
}
# This query is identical to the good query except that it comments out the name and id from the PostInterface2 fragment for Award
# This query fetches posts and their associated awards.
# It includes inline fragments to handle different post types/interfaces
# It does not work because it requests different fields in some of the fragments for awards
query BadQuery {
posts {
__typename
awards {
__typename
id
name
}
... on CompactPost {
__typename
id
awards {
__typename
id
name
}
}
... on PostInterface2 {
__typename
id
awards {
__typename
# name
# id
}
}
}
}
Describe the bug
In a system with: 1 type (CompactPost) and 2 interfaces (PostInterface1, PostInterface2), when requesting different selections sets from the types/interfaces, the output differs depending on which selection set requests all fields or fewer fields.
To Reproduce
A repository with a reproduction is here:
https://github.com/montykamath/gqlgen-bug-repro-1
cd b; make run
Expected behavior
Expect the output to be a deep merge of the selection sets into a single response list, rather than allowing the JSON writer to select the last of the duplicate keys.
The working query
Working query produces this output
The failing query
Failing query produces this output
The text was updated successfully, but these errors were encountered: