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 AvailableShippingMethod.method_code when no shipping methods are available #524

Closed TomashKhamlai closed 5 years ago

TomashKhamlai commented 5 years ago

Preconditions (*)

  1. Create Customer with US address (default billing and default shipping address)

Steps to reproduce (*)

  1. Navigate to Stores> Settings>Configuration>Sales>Shipping Methods and turn off Flat Rate
  2. Enable Free Shipping but go to Ship to Applicable Countries and uncheck Use Default
  3. In Ship to Specific Countries set country to United Kingdom only.
  4. In Show Method if Not Applicable set Yes
  5. Get Customer Token
  6. Create empty Cart
  7. Add simple product to cart
  8. Execute query cart:

query { cart( cart_id: "mfdHyHY0QgtXW5LeHxfJ0nVCjWjy655n" ) { available_payment_methods { code title } shipping_addresses { available_shipping_methods { carrier_title method_code } }

} }


### Expected result (*)
<!--- Tell us what do you expect to happen. -->

"available_shipping_methods": [ { "carrier_code": "freeshipping", "carrier_title": "Free Shipping", "method_code": null, "method_title": null, "error_message": "This shipping method is not available. To use this shipping method, please contact us.", "amount": 0, "base_amount": null, "price_excl_tax": 0, "price_incl_tax": 0, "available": false }


### Actual result (*)
<!--- Tell us what happened instead. Include error messages and issues. -->
1. Internal Server Error:
```graphql
{
  "errors": [
    {
      "debugMessage": "Cannot return null for non-nullable field AvailableShippingMethod.method_code.",
      "message": "Internal server error",
      "category": "internal",
      "locations": [
        {
          "line": 10,
          "column": 9
        }
      ],
      "path": [
        "cart",
        "shipping_addresses",
        0,
        "available_shipping_methods",
        0,
        "method_code"
      ]
    }
  ],
  "data": {
    "cart": {
      "available_payment_methods": [
        {
          "code": "checkmo",
          "title": "Check / Money order"
        }
      ],
      "shipping_addresses": [
        {
          "available_shipping_methods": [
            null
          ]
        }
      ]
    }
  }
}
naydav commented 5 years ago

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