Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear spec for array with fragments #1079

Closed
njlr opened this issue Feb 15, 2024 · 1 comment
Closed

Unclear spec for array with fragments #1079

njlr opened this issue Feb 15, 2024 · 1 comment

Comments

@njlr
Copy link

njlr commented Feb 15, 2024

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.

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 {}.

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: fsprojects/FSharp.Data.GraphQL#458

@njlr
Copy link
Author

njlr commented Feb 15, 2024

Dupe of #1080

@njlr njlr closed this as completed Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant