Skip to content

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

Open
@xperiandri

Description

@xperiandri

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)

query GetMostPopularStallProduce {
  mostPopularStall {
    availableProduce {
      ...  on Fruit {
        hasEdibleSeeds
      }
    }
  }
}

I've got

{
  "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
type Stall {
  availableProduce: [Produce]
}
  1. Not tullable items
type Stall {
  availableProduce: [Produce!]
}

In context of fixing fsprojects/FSharp.Data.GraphQL#455 in fsprojects/FSharp.Data.GraphQL#458

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions