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.
My Questions:- 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?