GraphQL query to access first item in an array?

No, GraphQL does not provide any syntax for manipulating the request, outside of conditionally including/excluding fields using the @skip and @include directives.

The GraphQL service you are querying may support a way to limit the result set for a field to a specific length by providing an argument on the field like limit, first or last. However, it's up to the server to include these fields as part of the service's schema and to provide the logic to implement them. Check your API's documentation to see if these fields are supported.

Any manipulations of the response have to be done client-side. There is an experimental graphql-lodash library that lets you do this right inside your queries -- but at the end of the day, the data is still being transformed client-side.

Tags:

Graphql