Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Cannot return null for non-nullable field CartItemQuantity.cart_item_id. #822

Closed
TomashKhamlai opened this issue Aug 13, 2019 · 0 comments
Closed
Assignees
Labels

Comments

@TomashKhamlai
Copy link
Contributor

Preconditions (*)

  1. Simple Product 1 has IN_STOCK status

Steps to reproduce (*)

  1. Add "Simple Product 1" to Cart
  2. Set shipping address on Cart
  3. Set the shipping method on Cart
  4. Try to set "email" on Cart and check some details in the Shipping addresses subselection
mutation {
  setGuestEmailOnCart(input:{
    cart_id: " {{guest_cart_id}} "
    email: "[email protected]"
  }){
     cart {
      email
      shipping_addresses {
        cart_items {
          cart_item_id
          quantity
        }
        items_weight
        selected_shipping_method {
          method_title
          
        }
        available_shipping_methods {
          carrier_code
          method_code
        }
      }
    }
  }
}

Expected result (*)

  1. It seems like it was working without exception until there were only downloadable products. So at least it should return null and no exception.
  2. Works as expected

Actual result (*)

  1. Error
{
  "errors": [
    {
      "debugMessage": "Cannot return null for non-nullable field CartItemQuantity.cart_item_id.",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 6,
          "column": 11
        }
      ],
      "path": [
        "setGuestEmailOnCart",
        "cart",
        "shipping_addresses",
        0,
        "cart_items",
        0,
        "cart_item_id"
      ]
    }
  ],
  "data": {
    "setGuestEmailOnCart": {
      "cart": {
        "shipping_addresses": [
          {
            "cart_items": [
              null
            ],
            "items_weight": 1,
            "selected_shipping_method": {
              "method_title": "Fixed"
            },
            "available_shipping_methods": [
              {
                "carrier_code": "flatrate",
                "method_code": "flatrate"
              }
            ]
          }
        ]
      }
    }
  }
}
@TomashKhamlai TomashKhamlai added bug Something isn't working Component: QuoteGraphQl labels Aug 13, 2019
@pmclain pmclain self-assigned this Aug 24, 2019
pmclain added a commit to pmclain/graphql-ce that referenced this issue Aug 24, 2019
[`\Magento\Quote\Model\Quote\Address::getAllItems`](https://github.com/magento/magento2/blob/cf4dc427fed594f74b7168735ee1eb93febfc143/app/code/Magento/Quote/Model/Quote/Address.php#L592-L636) returns
`\Magento\Quote\Model\Quote\Address\Item[]` when the quote has multiple
shipping addresses and `Magento\Quote\Model\Quote\Item[]` with a single
shipping address. These objects have different methods for accessing the quote
item id and both variants need to be accommodated in the extractor.

Fixes magento#822
@lenaorobei lenaorobei added this to the Release: 2.3.4 milestone Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants