magento2: GraphQl Cart Errors not retreivable

If the cart has an error, (eg. because of too low stock), you can’t retrieve this error through GraphQl. The error is thrown when you try to place an order through GraphQl. But this is to late in the process.

Preconditions (*)

  1. Magento 2.3.4 Open Source

Steps to reproduce (*)

  1. Add a product to your cart through GraphQl
  2. Lower stock of product to below the amount in cart or set product out of stock.
  3. Retrieve Cart information through GraphQl.

Expected result (*)

  1. The ability to have access to the hasError value of the Cart
  2. The ability to have access to the errorInfo value of the CartItem

Actual result (*)

  1. Error information is unavailable through GraphQl.
{
  "data": {
    "cart": {
      "prices": {
        "grand_total": {
          "currency": "USD",
          "value": 34
        }
      },
      "id": "Y4jQzWw93pta8ZLNEeBwygwQlQPbsEyB",
      "items": [
        {
          "id": "5",
          "quantity": 1,
          "product": {
            "name": "Joust Duffle Bag",
            "sku": "24-MB01",
            "description": {
              "html": ""
            }
          }
        }
      ]
    }
  }
}

Additional info

If try to View and Edit Cart from Storefront, error messages appear about Product out of stock out_of_stock

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@DrewML that is the case that @sasha19957099 demonstrated is now working as expected. The fix in #27015 fixed the CartItems resolver to handle errors (like product out of stock) in a better way.