Closed njlr closed 9 months ago
In this page, there is an interactive example for playing with fragments.
availableProduce returns an array of Produce, which is an interface. Using fragments, we can match on only Fruit items.
availableProduce
Produce
Fruit
Here is the query:
{ mostPopularStall { availableProduce { ... on Fruit { name hasEdibleSeeds } } } }
Then the response is:
{ "data": { "mostPopularStall": { "availableProduce": [ { "name": "pear", "hasEdibleSeeds": false }, { "name": "blueberry", "hasEdibleSeeds": true }, { "name": "banana", "hasEdibleSeeds": false }, {}, {} ] } } }
Notice how the non-matching items (type Vegetable) have been returned as empty objects {}.
Vegetable
{}
This behavior makes sense, however I was unable to find this documented in the spec.
What is the correct behavior here?
Sorry in advance if I have simply missed the relevant section!
Related PR: https://github.com/fsprojects/FSharp.Data.GraphQL/pull/458
Dupe of https://github.com/graphql/graphql-spec/issues/1080
In this page, there is an interactive example for playing with fragments.
availableProduce
returns an array ofProduce
, which is an interface. Using fragments, we can match on onlyFruit
items.Here is the query:
Then the response is:
Notice how the non-matching items (type
Vegetable
) have been returned as empty objects{}
.This behavior makes sense, however I was unable to find this documented in the spec.
What is the correct behavior here?
Sorry in advance if I have simply missed the relevant section!
Related PR: https://github.com/fsprojects/FSharp.Data.GraphQL/pull/458