All things Shopify and commerce
I'm using the Shopify GraphQL Admin API (version 2025-04) and the productSet mutation to update or create products. However, I’ve noticed that if I don’t include existing metafields in the request, they get deleted.
To prevent this, my current approach is:
Fetch existing metafields using a GraphQL query.
Merge them with the new metafields I want to add.
Send everything back in productSet.
The issue is that while I’m fetching the metafields, they might have been updated externally, meaning I could end up sending outdated data and unintentionally overwriting recent changes.
Is there a way to use productSet without affecting existing metafields?
If not, is there an alternative method to update metafields separately without deleting them?
What’s the best practice for ensuring metafields remain intact while updating products?
I have the same problem myself.
It's suprising that you can't use upSert and CustomId without “emptying” the existing metafields.
The solution, which is to retrieve the metafields upstream and send them back, only works if no changes are made to the Shopify data during the time-lapse between retrieval and push.
I doubt we're the only ones to encounter these issues.
Any feedback would be appreciated.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025