Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Multiple updateCustomer mutations with same "addresses" payload will remove address

Solved

Multiple updateCustomer mutations with same "addresses" payload will remove address

rossbrown
Shopify Partner
3 0 4

I'm running into an issue with updating Customer addresses with the `updateCustomer` mutation. The first time I call `updateCustomer` with `addresses` in the payload, it updates the Customer as expected, adding the address and setting as the default. However, if I run the mutation again with the exact same payload, the Customer response comes back with an empty addresses array and no default address. This can be continued ad infinitum. Each time an address is submitted with the update that is identical to the existing default address of the Customer, it is removed entirely.

 

Here is a gist with the mutation and variables used to recreate the issue: https://gist.github.com/albatrocity/25d37436c864bc16162f836b10df978d

 

Is this a bug in the GraphQL Admin API or expected behavior? I would expect the second call to overwrite the customer's addresses or to merge the new one into the existing list. Instead, it seems to blow away all associated addresses.

Accepted Solution (1)

lizk
Shopify Staff
246 58 79

This is an accepted solution.

Hi 

Thanks for flagging this issue!

The team is currently aware of this behaviour.

In the mean time the work around to for your expected functionality, the second call not removing the address, is to ensure you have the address id, of the address you would like to update in the input for the CustomerUpdate mutation.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 11 (11)

lizk
Shopify Staff
246 58 79

This is an accepted solution.

Hi 

Thanks for flagging this issue!

The team is currently aware of this behaviour.

In the mean time the work around to for your expected functionality, the second call not removing the address, is to ensure you have the address id, of the address you would like to update in the input for the CustomerUpdate mutation.

To learn more visit the Shopify Help Center or the Community Blog.

emartinello
Shopify Partner
1 0 0

Is the problem still not resolved? The ids are not present in the customer addresses, how can I update the addresses without risking deleting them?

ritx
Shopify Partner
3 0 0

Hi,

 

Any update on this issue? It really is a problem to have to query and verify each client and their addresses in any update, especially for bulk updates, it makes the purpose of the bulk update useless.

MorelDev
Visitor
2 0 1

Hello,

 

Is there any hope that this bug will be fixed soon? All our developments have been done in REST and we are in the process of switching over to bulk mutations.

 

This malfunction calls our project into question. Thank you for the update, so that we can make the best decisions.

 

Why does a reply to this topic say "This is an accepted solution. ? The proposed workaround is not functional.

 

Have a nice day

MorelDev
Visitor
2 0 1

I've found an acceptable workaround...

 

The bug does not occur if the data changes.

In the case where the new data is exactly the same, we have chosen to alternately feed the first name or the last name, with the value "first name + last name" and empty for the other field.

 

If it helps other people in the community...

Lishan
Shopify Partner
15 1 4

The problem still persists. Also the the address id is already deprecated so we can't use that as suggested.. to get around the issue.

 

I ended up using REST API instead and it works well. 

lauri_jalonen
Shopify Partner
6 0 4

Great find @Lishan!
It puzzles me that the solution proposed by @lizk is now deprecated and we're actually reverting to REST...
Isn't Shopify wanting devs to adopt GraphQL? 

Just in time for your next adventure

lauri_jalonen
Shopify Partner
6 0 4

@lizk 
Same issue using GraphQL Admin API 2024-04. Here's a Loom showing the behaviour. On subsequent customerUpdate calls, the address gets removed and then re-added, each time having a different ID.

https://www.loom.com/share/8bf9cf43c4ab4b62a2a2671b95a66585?sid=67495513-988d-4a20-b80e-7f33a20919f3

Just in time for your next adventure

gfernandez
Shopify Partner
2 0 1

this is not solved, can you change the status to not solved?

victorvila
Shopify Partner
2 0 2

same issue here. @lizk do you have any updates?

ShopifyDevSup
Shopify Staff
1453 238 530

Hi @victorvila,

 

There's no updates on this issue at this time. Though I can assure you that I have reached out to our developers again to ensure that issue is being investigated and worked on with the correct priority. That said due to the technical nature of issues such as these and the various parts of the platform any changes may affect, we are unable to provide any estimated timeframes for when this will be resolved.

In the meantime while our developers are looking into this further, for a workaround I may suggest making use of our new Customer Account API, which does have a customerAddressUpdate mutation that you can use to update the address specifically to prevent this issue from occurring.
 

 

I hope this helps, and I hope you have a great day 🙂

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog