Always return a full object of specific GraphQL type [duplicate]

This question already has an answer here:

Is there a way to tell GraphQL to always return a full object of specific type?

If I ask GraphQL endpoint for something like this:

query {
  FooList {
    id
    price
    location
  }
}

I will get error Field "price" of type "Price" must have a sub selection."

The correct way is to ask instead

query {
  FooList {
    id
    price {
        amount
        currency
    }
    location {
        lat
        lng
    }
  }
}

It makes sense for most objects that you have to ask for details that you need,
but some like GPS coordinates, or price mentioned above will always return all fields
(there is no point in getting just latitude)

Is it possible to mark a class in GraphQL schema to always return full object?

I am using overblog/GraphQLBundle as the server.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *