Type \"[ArrayResult]\" must have a selection of subfields error

I have a custom class called Item. It has a fruit property of type Array. There is an object in that class where the fruit property value has been set to ["apple", "orange"].

When I query for an item in the playground:

query {
  item(id: "gKTdECrXci") {
    fruit
  }
}

I get an error:
"message": "Field \"fruit\" of type \"[ArrayResult]\" must have a selection of subfields. Did you mean \"fruit { ... }\"?"

There is also an error in the left panel:

image

I’m unsure how to proceed, and can’t seem to find this type of scenario mentioned in the Parse docs. I’d like to return an array of fruit in my graphql query. Any suggestions?

Since Parse Schema do not allow to type the content of an Array Field. The ArrayResult follow the inline fragment GraphQL spec (It’s a union type). To get the content of the array you need to use something like this. (Not tested)

Here graphql doc about inline fragments : https://graphql.org/learn/queries/#inline-fragments

query {
  item(id: "gKTdECrXci") {
    fruit {
     ... on Element {
      value
     } 
    }
  }
}

This kind of union time allow developers to store what they want (also Pointers) into the array !

Thanks very much. That works.