Clearing Metafield Data on Specific Product with GraphQL

I need to “clear” values on specific MetaFields with Type “single_line_text_field” but only on specific products using the GraphQL API.

As I understand it we cannot send a blank value when running the mutation metafieldsSet, as I initially tried this but it won’t take it.

If I try metafieldDelete mutation I am afraid that it will delete the MetaField everywhere.

I simply need to clear it on a specific set of Products/Product.

Any way to do this, as I am not seeing any way of doing this with the API?

Hi Stats_marketing,

Just to confirm, you’d like the same ability that existing in the admin where there’s an option to clear a products metafield value, but just via the API?

1 Like

Hi again,

I’ve looked into this more and it appears the metafieldDelete mutation will clear just the value of the specified metafield, but it won’t delete the value of every instance of the metafield.

The metafieldDefinitionDelete mutation will remove the metafield fully from the store.

1 Like

I would like this!

To clear values in specific MetaFields of type “single_line_text_field” for certain products using the GraphQL API, you need to set the MetaField value to an empty string for each specific product. This approach ensures that the MetaField is cleared only for the selected products without deleting it globally. Unlike a private haushaltsauflösung in der nähe where you can selectively clear specific items without affecting others, the GraphQL API allows you to clear MetaField values for specific products by setting them to an empty string, ensuring precision and control over which MetaFields are cleared.