How do I create a GraphQL mutation for updating the CountryCodeV2?

Highlighted
New Member
1 0 0

Hi All,

I am struggling with the mutation to update the CountryCodeV2 which is an enum, 

mutation customerUpdateDefaultAddress($customerId: ID!, $addressId: ID!) {
  customerUpdateDefaultAddress(customerId: $customerId, addressId: $addressId) {
    customer {
      id
      addresses{
        countryCodeV2: countryCodeV2 ## How to pass DE overhere?
      }
    }
    userErrors {
      field
      message
    }
  }
}

Thanks!

0 Likes
Highlighted
Shopify Staff
Shopify Staff
592 72 131

Hey @shreyathakkar,

The mutation you're using is meant to update which address is used as the customer's default address (when a customer profile contains > 1 address). If you're looking to update information in the address itself, you can use the customerUpdate mutation.

This mutation updates the countryCode on the default address for the supplied customer_id. You can also specify an address_id if you'd like to update the non-default address.

mutation customerUpdate($input: CustomerInput!) {
  customerUpdate(input: $input) {
    customer {
      id
    }
    userErrors {
      field
      message
    }
  }
}
{
"input": {
  "id": "gid://shopify/Customer/2197622489110",
  "addresses": [
   {
    "countryCode": "DE"
   }
  ]
 }
}

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes