graphql / graphql/graphql-spec

What must be the result of executing only one fragment on a list of union or interface type?

Open
#1,080 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Having types `Fruit` and `Vegetable` implementing `Produce` as per https://graphql.com/learn/interfaces-and-unions/#fragments
After I executed such query (use no shared fields, and only a sible type fragment while the collecton has multiple types)
```graphql
query GetMostPopularStallProduce {
mostPopularStall {
availableProduce {
... on Fruit {
hasEdibleSeeds
}
}
}
}
```
I've got
```JSON
{
"data": {
"mostPopularStall": {
"availableProduce": [
{
"hasEdibleSeeds": false
},
{
"hasEdibleSeeds": true
},
{
"hasEdibleSeeds": false
},
{},
{}
]
}
}
}
```
**Is it the correct behavior?**

Specification does not mention such case at all.

**I want to understand both cases like:**
1. Nullable items
```graphql
type Stall {
availableProduce: [Produce]
}
```
2. Not tullable items
```graphql
type Stall {
availableProduce: [Produce!]
}
```

In context of fixing https://github.com/fsprojects/FSharp.Data.GraphQL/issues/455 in https://github.com/fsprojects/FSharp.Data.GraphQL/pull/458

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.