Description
Summary
I have an union type union Animal = Cat | Dog
and a root field called animals(input: [AnimalIdsAndTypesInput!]!): [Animal]!
. AnimalIdsAndTypesInput
contains two fields called id
and type
. type
can be either CAT
or DOG
. This field should return the cats and dogs in the same order as the input ids and types. However, depending on the order of the input array, it produces nulls for some extended fields in Cat.
Steps to reproduce
- Use the reproduction branch: ouch-my-finger
- Run the
schema.sql
file against the database to create the cat and dog tables and insert some dummy data. - Start postgraphile.
- Execute the following
Query 1
andQuery 2
.
Query 1
query MyQuery {
animals(input: [
{id: "2", type: "CAT"},
{id: "1", type: "DOG"}
]) {
... on Dog {
id
name
ownerName
}
... on Cat {
id
name
enemies
}
}
}
Query 2
query MyQuery {
animals(input: [
{id: "1", type: "DOG"},
{id: "2", type: "CAT"}
]) {
... on Dog {
id
name
ownerName
}
... on Cat {
id
name
enemies
}
}
}
- In the above two queries, the only difference is the order of the two input objects.
Expected results
enemies
of the Cat
type should receive the expected JSON value.
Actual results
enemies
of the Cat
type receives null.
Additional context
I know the enemies field here can use a plan instead of custom sql execution. However, in my case it's more complex than this reproduction. Also, instead of loadMany
I have tried withPgClient
which returns no results, but an array of nulls.
When I said order of the fields, specifically this happens, when you put the extended type (in this case, it's the Cat
type) later in the array of input objects.
Metadata
Metadata
Assignees
Type
Projects
Status
🦔 Hedgehog
Activity