Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
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
}
}
}
}
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.
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" } ] } }
I use the same method to work around the bug.
However, I don't know if this is the right way and I would like an official answer.
You can refer this link: https://shopify.dev/api/admin-graphql/2021-07/input-objects/CustomerInput