magento2: [GraphQl] Cart error messages are faulty
Preconditions (*)
- Magento 2.4.2+
Steps to reproduce (*)
- Create a cart
- Add 2 products to the cart with at least 4 quantities each.
- Set the quantity of added products below the quantity in the cart.
- Retrieve cart through graphql
{
cart(cart_id: "RQg4YPcQX1htp47j6GMpTKRshfY6SVm6") {
items {
id
product {
name
sku
stock_status
}
quantity
}
}
}
Expected result (*)
- A error message which tells me which item in the cart causes the error. So that we can give correct feedback to the Customer.
- A cart with valid values for items.
- An error message for each issue with the cart.
Actual result (*)
{
"errors": [
{
"message": "The requested qty is not available",
"extensions": {
"category": "graphql-input"
},
"locations": [
{
"line": 7,
"column": 5
}
],
"path": [
"cart",
"items",
0
]
}
],
"data": {
"cart": {
"items": [
null,
{
"id": "32",
"product": {
"name": "Strive Shoulder Pack",
"sku": "24-MB04",
"stock_status": "IN_STOCK"
},
"quantity": 3
},
{
"id": "33",
"product": {
"name": "Joust Duffle Bag",
"sku": "24-MB01",
"stock_status": "IN_STOCK"
},
"quantity": 4
}
]
}
}
}
- In the items node there is a null entry, this only shows up when there is an error. In default Venia this breaks the cart page.
- I assume the path node in the error node should reference the item it’s affecting. It currently points to the above null value.
- Only the first error of the cart shows up.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 28 (6 by maintainers)
@Usik2203 I’d rather have something that has to be unique to identify the product, because the product name can be identical for products. Also your solution doesn’t solve the null object that suddenly got added to the items array.
Thanks, @Hexmage the provided code is helpful; one more note here is to add to di.xml
They removed the module : https://github.com/magento/magento2-pwa/commit/96c5f5f2ed31865f0b87f096221ddb9245f194da
@marwan-corals The Plugin
The schema.graphqls additions
@engcom-Hotel I also consider the fact that a null object appears in the items node when an error occurs very crucial to resolve. As it currently breaks default Venia.