Updating Product metafields via graphQL productSet

Topic summary

A developer is encountering issues when managing product metafields through the GraphQL productSet mutation.

Primary Issues Identified:

  1. Unstructured metafields not returned: While unstructured metafields (those without definitions) are successfully created and visible in the Shopify admin, they are not returned in API responses—neither from productSet mutations nor product queries.

  2. Restored metafields not returned: When a metafield with a definition is deleted via productSet (by removing it from the input list) and later re-added, it gets created successfully and appears in the admin interface. However, it fails to appear in subsequent API responses.

Proposed Workarounds:

Another user suggested:

  • Creating metafield definitions in Shopify admin for all metafields
  • Avoiding full deletion by clearing values instead, then refilling when needed

Developer’s Response:

The original poster rejected these workarounds, arguing they are treating symptoms rather than addressing API bugs. They maintain that:

  • Unstructured metafields should be returned by the API if they can be created via API
  • Re-created metafields should behave identically to newly created ones

The discussion remains unresolved, with the developer seeking proper API fixes rather than workarounds.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

I create and update products via graphQL productSet calls:
https://shopify.dev/docs/api/admin-graphql/latest/mutations/productset

I found a few problems with creating/udating/deleting metafields with this mutation:

  1. On creating the Product I supply a list of MetafieldInputs. For each MetafieldInput I supply the fields: namespace, type, key, value.

  2. All metafields are created, I can see them in https://admin.shopify.com, including metafields with definitions and unstructured metafields .

  3. But in the returned productSet product object, only metafields that have definitions are returned. Unstructured metafields are not returned.

  4. When I read the product using the product query, the same, only metafields that have definitions are returned. Unstructured metafields are not returned.

  5. Further I am talking about metafields with definitions.

  6. I can change a metafield value of an existing metafield changing the value for the corresponding key in the MetafieldInputs and using productSet. API returns the list with the changed value. It is fine.

  7. I can remove a metafield deleting it from the MetafieldInputs list and using productSet. The metafield is removed, API returns the list with this metafield absent. In https://admin.shopify.com this metafield field is still present but its value is empty. I think it is probably fine.

  8. Then I try to restore this metafield. I add it again to the MetafieldInputs list and use productSet. The matafield is actually added again, I can see it in https://admin.shopify.com with the new value. But it is not returned in API productSet product object. And when I read the product using the product query, the same, this newly added metafield is not returned.

So the problems:

  1. Unstructured metafields are never returned by API (nor on productSet return, nor on product query).

  2. A deleted metafield with a definition, and then restored (added again) are never returned by API (nor on productSet return, nor on product query).

Hi,

Hope this will help

  • Unstructured metafields not showing: Add definitions in Shopify admin
  • Deleted-defined metafields not returning : Don’t fully remove from input; just clear and re-fill value

Code example:

{
  namespace: "your_namespace",
  key: "your_key",
  type: "single_line_text_field",
  value: "new value"
}

Thank you very much!

But I do not want to use some tricks to avoid the API issues. I want the API to be fixed.

  1. I do not want to define definitions for all metafields. I prefer to have some of them for particular products to be unstructured. There is no reason in handling unstructured metafields in API differently. If you can create an unstructured metafield via API, why does the API not return it in the response and why cannot you read them along other metafields on product queries? It is definitely incorrect behavior.

  2. I do not want to clear metafield values. The API is clearly has ability to delete metafields if you want. And I want to delete unwanted metafields from products completely. And the API allow to delete them. It is correct. What is incorrect, if after some time in the future you need to create the matafield with the same key again, API creates it, it is OK, but it does not return it in API productSet product object. And when I read the product using the product query, the same, this newly added metafield is not returned. It is definitely incorrect behavior.