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:
- the metafields are not private metafields
- I’m using GraphQL API version 2023-04
- the token I’m using has the read_products and write_products permissions