Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I believe I understand why I am getting this error- my checkout ID is invalid.
I believe this will inevitably happen if my users' checkout gets stale, so I am trying to write code that deals with this error.
Here is the mutation:
mutation checkoutLineItemsAdd ($checkoutId: ID!, $lineItems: [CheckoutLineItemInput!]!) {
checkoutLineItemsAdd(checkoutId: $checkoutId, lineItems: $lineItems) {
userErrors {
message
field
}
checkoutUserErrors {
code
message
field
}
checkout {
...CheckoutFragment
}
}
}
Here is the JSON that gets returned from the request:
{
"data": {
"checkoutLineItemsAdd": {
"userErrors": [
{
"message": "Checkout does not exist",
"field": [
"checkoutId"
],
"__typename": "UserError"
}
],
"checkoutUserErrors": [
{
"code": "INVALID",
"message": "Checkout does not exist",
"field": [
"checkoutId"
],
"__typename": "CheckoutUserError"
}
],
"checkout": null,
"__typename": "CheckoutLineItemsAddPayload"
}
}
}
I am trying to write code that deals with this case, but I am having trouble understanding the documentation on the error.
I am currently referring to this documentation:
https://shopify.dev/api/storefront/2022-01/objects/CheckoutUserError
https://shopify.dev/api/admin-graphql/2022-01/objects/UserError
this is the main mutation I am trying to do: https://shopify.dev/api/storefront/2022-01/mutations/checkoutLineItemsAdd
I have two main questions:
1) why are both errors in this case being triggered?
2) is there any case where this error is included where it's not fatal to the request? (since the docs don't link the possible error states for the mutation I don't know how to look this up)
Is there any documentation specifically related to this error?
Is there a prefered way to handle this error? Should I only look for userError, or do I need to look for checkoutUserError in specific cases?
How can I know that checkoutUserError seems to inherit from userError in some way?
I also cannot find a list of possible error states anywhere in the docs- for example is there a page that mentions "Checkout does not exist" specifically? Shouldn't I be able to find this in the doc pages above?
thanks in advance.