magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 156 forks source link

Cannot return null for non-nullable field SelectedShippingMethod.amount #402

Closed TomashKhamlai closed 5 years ago

TomashKhamlai commented 5 years ago

Cannot return null for non-nullable field SelectedShippingMethod.amount when querying "selected_shipping_method" on "setShippingAddressesOnCart" mutation no matter shipping_addresses.address or shipping_addresses.customer_address_id is used

Preconditions (*)

  1. Registered Customer
  2. Simple Product
  3. Virtual Product
  4. Developer mode

Steps to reproduce (*)

  1. Generate Customer token
  2. Create empty cart as Registered Customer from GraphQL Client
  3. Add simple and virtual products to cart from GraphQL Client but use
    ...
    cart {
      items {
        id
        __typename
    ...

    in output

  4. Get ADDRESS_ID by hovering 'Change Billing Address' or 'Change Shipping Address'
  5. Set
    mutation {
    setShippingAddressesOnCart(
    input: {
      cart_id: "{{ CART_ID }}"
      shipping_addresses: {
        customer_address_id: 3
        cart_items: [{
          cart_item_id: 11
          quantity: 1
        }
        {
          cart_item_id: 12
          quantity: 1
        }]
      }
    }
    ) {
    cart {
      cart_id
      shipping_addresses {
        address_type
        available_shipping_methods {
          carrier_code
          carrier_title
          method_code
          method_title
          price_excl_tax
          price_incl_tax
        }
        selected_shipping_method {
          amount
        }
      }
    }
    }
    }

Expected result (*)

  1. Some tip for guessing what is wrong

Actual result (*)

  1. "Cannot return null for non-nullable field SelectedShippingMethod.amount.
    {
    "errors": [
    {
      "debugMessage": "Cannot return null for non-nullable field SelectedShippingMethod.amount.",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 16,
          "column": 11
        }
      ],
      "path": [
        "setShippingAddressesOnCart",
        "cart",
        "shipping_addresses",
        0,
        "selected_shipping_method",
        "amount"
      ]
    }
    ],
    "data": {
    "setShippingAddressesOnCart": {
      "cart": {
        "cart_id": "rzQ6tNveErjEWMWzDJMVlnfgtkhiVPOu",
        "shipping_addresses": [
          {
            "address_type": null,
            "available_shipping_methods": [
              {
                "carrier_code": "flatrate",
                "carrier_title": "Flat Rate",
                "method_code": "flatrate",
                "method_title": "Fixed",
                "price_excl_tax": 10,
                "price_incl_tax": 10
              }
            ],
            "selected_shipping_method": null
          }
        ]
      }
    }
    }
    }
naydav commented 5 years ago

https://github.com/magento/graphql-ce/pull/417