A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm trying to update two product metafields using the GraphQL API.
The metafields were created through the Shopify Admin Custom Data section with Content Type 'Single line text'.
The mutation I send looks like this:
mutation { productUpdate (input: { id: "gid://shopify/Product/1", metafields: [ { id: "gid://shopify/Metafield/1", value: "Value1" }, { id: "gid://shopify/Metafield/2", value: "Value2" } ] }) { product { id metafields(first: 10) { edges { node { id namespace key value } } } } } }
(Note: I changed the IDs and values above before posting here)
The request returns 200 but the Metafields do not get updated.
The response looks like this:
{"id":"gid://shopify/Product/1","metafields":{"edges":[]}}
Any idea where I'm going wrong? Thanks
Side note:
I noticed that if I change the metafields ID to something random, the request still returns 200. It's like the metafields property of the mutation is being ignored.
Additional info:
I observed that the userErrors states that the namespace, key and type could not be blank.
After adding these fields, the update was successful, although the docs state the fields are optional when updating a metafield in the following articles:
I think that either the docs are wrong or the API has a bug.