Overview
I have simple server-side validation function that raises an error if subtotal>$1000 that mimics the official published example here via docs. It’s triggered when items are added or updated in the cart. It works as expected inside a liquid-driven storefront cart (via the Cart Ajax API) and raises the error message inside of checkout too with no problems as shown here:
However, when calling GraphQL “cart update” mutations (cartLinesAdd, cartLinesUpdate), the GraphQL endpoint returns a failure INTERNAL_SERVER_ERROR message.
Thoughts1. The checkout validation function certainly is the reason behind the failure. If the cart doesn’t meet the conditions for “validation failure”, then the GraphQL calls succeed with no issue.
- Using the graphiql util or another GraphQL client like Postman or Insomnia work fine (cart items are added/updated) until the “validation failure” threshold is met.
- Attempting this in context of a React/Remix Hydrogen storefront which uses GraphQL to manipulate the cart.
Expectations
Expecting something other than an INTERNAL_SERVER_ERROR. Perhaps this is normal? Regardless, it’s impossible to trap and handle properly since the error payload isn’t returned. Instead its the unhelpful INTERNAL_SERVER_ERROR.
GraphQL Query
mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!, $country: CountryCode = GB, $language: LanguageCode = EN) @inContext(country: $country, language: $language) {
cartLinesAdd(cartId: $cartId, lines: $lines) {
cart {
...CartApiMutation
}
errors: userErrors {
...CartApiError
}
}
}
fragment CartApiMutation on Cart {
id
totalQuantity
}
fragment CartApiError on CartUserError {
message
field
code
}
Variables
{
"cartId": "gid://shopify/Cart/c1-70eTHECARTIDISHERE",
"lines": [
{
"merchandiseId": "gid://shopify/ProductVariant/SOMEVARIANTID",
"quantity": 1
}
]
}
Error Output
{
"errors": [
{
"message": "Internal error. Looks like something went wrong on our end.\nRequest ID: f33e7361-0f30-46d6-84d7-b5cf30392c2b (include this in support requests).",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"requestId": "f33e7361-0f30-46d6-84d7-b5cf30392c2b"
}
}
]
}


