Expected Behavior
The graphql method returns the errors from the GraphQL API when encountered.
Actual Behavior
The graphql method currently returns only the data, and not the errors from the GraphQL API when encountered.
In particular, when the data is empty due to an error, there is no access to the error information to understand why, or to know that there was an error at all. Try-catching has no effect as errors are only thrown when there is a json parsing error, but this makes sense as GraphQL is meant to still be able to provide data even when errors are encountered.
Fixing the query for the method call returns the data, but without the usual wrapping { "data": ... } to provide room for an errors field:
{ inventoryItems: { edges: [ [Object] ] } }
Also, thanks for integrating GraphQL into the project! There are some features missing in the REST API like searching by query syntax, and still some missing in the GraphQL API like setting inventory levels directly, so having them both available side-by-side is very handy.
Package version 2.21.0
Expected Behavior The graphql method returns the errors from the GraphQL API when encountered.
Actual Behavior The graphql method currently returns only the data, and not the errors from the GraphQL API when encountered.
In particular, when the data is empty due to an error, there is no access to the error information to understand why, or to know that there was an error at all. Try-catching has no effect as errors are only thrown when there is a json parsing error, but this makes sense as GraphQL is meant to still be able to provide data even when errors are encountered.
For example, when asking for:
The response is an empty object:
Whereas the GraphQL API (tested with the Shopify GraphiQL App) returns an error message:
Fixing the query for the method call returns the data, but without the usual wrapping
{ "data": ... }
to provide room for anerrors
field:Also, thanks for integrating GraphQL into the project! There are some features missing in the REST API like searching by query syntax, and still some missing in the GraphQL API like setting inventory levels directly, so having them both available side-by-side is very handy.