MONEI / Shopify-api-node

Node Shopify connector sponsored by MONEI
https://monei.com/shopify-payment-gateway/
MIT License
946 stars 278 forks source link

GraphQL does not throw mutation errors #439

Open chris-rudmin opened 3 years ago

chris-rudmin commented 3 years ago

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.

lpinca commented 3 years ago

The field used to check for errors is errors:

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

chris-rudmin commented 3 years ago

@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

lpinca commented 3 years ago

Feel free to open a PR.