magento2: [GraphQL] CreateGiftRegisty mutation throws error when using country_code in CreateGiftRegistyInput

Issue 1:CreateGiftRegistryInput throws the below error when using "countrycode" in the shippingaddress.GiftRegistryShippingAddressInput.

Run the below query:

mutation{
  createGiftRegistry(
    giftRegistry:
    {
      event_name: "100th birthday"
      message:"test birthday"
      giftRegistryTypeUid:"MQ=="
      shipping_address:{
        address_data:{
          lastname:"thampy"
          firstname:"d"
          city:"Austin"
          street:"500 test street"
          telephone:"5126861521"
          postcode:"78681"
          country_code:US
          
        }
      }
      registrants:{
        lastname:"Doe"
        email:"test.customer@gmail.com"
        firstname:"John"
      }
      privacy_settings:PUBLIC
      status:ACTIVE
      }
  )
  {
    gift_registry{
      created_at
      dynamic_attributes{label value}
      registrants{ firstname lastname email}
      owner_name
      privacy_settings
      type {label uid dynamic*attributes_metadata{attribute_group label _*typename}}
      items{product{sku name}}
      uid
    }
  }
}
{code}
#### Expected Result:

Gift registry is created.
#### Actual Result

Please note that country*_id is deprecated in favor of country_code. However, if you use country_id instead of country*code, internal server error is returned.
{code:json}
{
  "errors": <
    {
      "message": "\"countryId\" is required. Enter and try again.",
      "extensions": {
        "category": "graphql-input"
      },
      "locations": [
        {
          "line": 23,
          "column": 3
        }
      ],
      "path": [
        "createGiftRegistry"
      ]
    }
  >,
  "data": {
    "createGiftRegistry": null
  }
}
{code}
#### Issue 2.

When you run the above createGiftRegistry mutation with country*id in the shipping_address, and if you are requesting dynamic*attributes {label value} in the CreateGiftRegistryOutput, then internal server error is returned. 
 See screenshot.
 !internal server error- giftRegistry.png|thumbnail!
#### Issue 3: Make sure 'created_at" returns correct data

Remove
{code:java}
dynamic_attributes {label value}```
from CreateGiftRegistryOutput, then you can see that created_at is returning empty
 !giftRegistry-created_at.png|thumbnail!
#### P.S.

Cloud instance where the issue can be reproduced:<https://24develop-2hpekvq-t6ea5z2gu335w.us-4.magentosite.cloud/>

About this issue

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

Most upvoted comments

@eduard13 One quick update on testing with the latest changes: When you run UpdateGiftRegistry mutation with shipping address and only set one of the optional fields, let’s say eithere"city" or “phone number”, the result returns error saying that you have to set “firstname”, and “lastname”, and “telephone”, and “street” and "country_id " even though they are not required fields.

See the screenshot for better reference:

updateGiftRegistry_shippingAddressRequired

@dthampy thank you for the screenshots, much clear now. I’ve finally got to this issue and investigating these problems. Will keep you posted.