Shopify-api-node icon indicating copy to clipboard operation
Shopify-api-node copied to clipboard

GraphQL does not throw mutation errors

Open chris-rudmin opened this issue 5 years ago • 3 comments

When doing a mutation shopify.graphql(mutationQuery) where the query is a mutation such as:

mutation {
  customerCreate(
    input: {
      ...
    }
  )
  {
    customer {
      id
      displayName
    }
    userErrors {
      field
      message
    }
  }
}

Errors are returned in the userErrors field. However the request promise resolves successfully. I was expecting the error to be thrown as it is done for normal queries.

chris-rudmin avatar Dec 02 '20 17:12 chris-rudmin

The field used to check for errors is errors:

https://github.com/MONEI/Shopify-api-node/blob/c949c7d28c4d701283dcf806060dc0cc20e607e7/index.js#L236-L246

lpinca avatar Dec 02 '20 20:12 lpinca

@lpinca I see that. According to all the Shopify docs I have seen. Mutation queries will have any error in the field userErrors

Some example doc references: https://shopify.dev/docs/admin-api/graphql/reference/customers/customeraddtaxexemptions https://shopify.dev/docs/admin-api/graphql/reference/customers/customercreate https://shopify.dev/docs/admin-api/graphql/reference/orders/ordereditsetquantity

chris-rudmin avatar Dec 02 '20 21:12 chris-rudmin

Feel free to open a PR.

lpinca avatar Dec 03 '20 06:12 lpinca