Exceptions
Any errors during resolution of a GraphQL query are returned as part of the API response.
Using GraphQL's introspection capabilities in conjunction with respective tooling allows to avoid many potential errors already during development. However of course, not all failures can be prevented.
Since a complex GraphQL query can involve many separate data sources to resolve various fields, the resolution can fail partially and still succeed in the remaining parts. That's why a response can contain a list of errors
in addition to a data
property.
Authorization Error
Unauthorized requests cannot be resolved properly. All top-level fields in the included query will default to null
and the failed resolutions be reported as part of the list of occured errors
.
Let's a ssume the following query to fetch similar products:
If this query would be sent in an unauthorized request (notice the missing x-api-id
header):
The result would list the failure:
Validation Error
For requests with invalid queries you will get back the information about what is wrong.
Let's assume we used a wrong argument in our query, i.e. sku
instead of id
:
The result would list the failure and hint on which line something is wrong:
Last updated