GraphQL Admin API - Updating Customer Addresses Bug?

Shopify Partner
10 0 1

 

Adding a new address to the addresses array deletes the previous entries and adds the new entry. 

Is this expected behavior? Or am I doing it wrong?

 

 

#Figure 1 - Create the addresses
mutation customerUpdate($input: CustomerInput!) { customerUpdate(input: $input) { customer { id addresses{ firstName lastName } } userErrors { field message } } }

{
"input": {
"id": "gid://shopify/Customer/701981458497",
"addresses": [
{
"firstName": "first",
"lastName": "last"
},
{
"firstName": "first2",
"lastName": "last2"
}
]
}


#Response
{
"data": {
"customerUpdate": {
"customer": {
"id": "gid://shopify/Customer/701981458497",
"addresses": [
{
"firstName": "first",
"lastName": "last"
},
{
"firstName": "first2",
"lastName": "last2"
}
]
},
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 11,
"actualQueryCost": 11,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 989,
"restoreRate": 50
}
}
}
}

 

#Figure 2 - Trying to add a new address
mutation customerUpdate($input: CustomerInput!) {
#Same as above ... }

{
"input": {
"id": "gid://shopify/Customer/701981458497",
"addresses": [
{
"firstName": "first",
"lastName": "last"
},
{
"firstName": "first2",
"lastName": "last2"
},
{
"firstName": "first3",
"lastName": "last3"
}
]
}


#Response
{
"data": {
"customerUpdate": {
"customer": {
"id": "gid://shopify/Customer/701981458497",
"addresses": [
{
"firstName": "first3",
"lastName": "last3"
}
]
},
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 11,
"actualQueryCost": 11,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 989,
"restoreRate": 50
}
}
}
}

 

1 Like
Highlighted
New Member
2 0 3

Same here. I can create a customer with multiple addresses as intended, but can't update them. It just replaces the whole addresses with the last address.

0 Likes
Highlighted
New Member
1 0 0

I add address `id` to overwrite existed address information

{
  "input": {
    "id": "gid://shopify/Customer/3430598705197",
    "addresses": [
      {
        "id": "gid://shopify/MailingAddress/3891714064429?model_name=CustomerAddress",
        "address1": "234cccd123c"
      }
    ]
  }
}

 

0 Likes