Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi,
I use the graphql productUpdate mutation to update a product as well as the product variants and metafields.
In general this works as expected, I can update metafield values as I want to. But I run into problems when I want to reset a metafield, i.e. when I set the metafield value to null.
If a metafield value before was e.g. "Apple" and I want to set it to null, nothing happens, the value is still "Apple". If I try to set it to '' or ' ' it does not work either. '-' works, but it is not a pretty solution.
I also tried not including the metafield in the metafield list, but the value of the metafield is still "Apple".
So to me it seems to be a bug?
Thanks,
-Louise
Hi Louise!
To delete a metafield you need to use a different mutation called metafieldDelete:
https://shopify.dev/api/admin-graphql/2021-10/mutations/metafieldDelete
To learn more visit the Shopify Help Center or the Community Blog.