A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi, I'm trying to add some tags to a product via productUpdate and I'm running into the problem that no matter what I pass is doesn't fail but the tags are not updated.
I'm sending this:
mutation {
productUpdate(input: {
id: "gid://shopify/Product/${id}",
title: "${data.title}",
descriptionHtml: "${data.descriptionHtml}",
metafields: [{
key: "mainmaterial",
namespace: "my_fields",
value: "${data.metafields.mainmaterial}"
}],
tags: ["Hest","Fisk"]
}) {
product {
id
descriptionHtml
images(first:50) {
edges {
node {
id
src
}
}
}
tags
metafields(first:10) {
edges {
node {
namespace
key
value
}
}
}
}
}
}
And I'm getting this in return:
{
id: 'gid://shopify/Product/7214229487809',
descriptionHtml: '...',
images: {
edges: [
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object], [Object],
[Object]
]
},
tags: [],
metafields: { edges: [ [Object] ] }
}
As you can see "tags" returns blank and I've confirmed in the admin section on the product that no tags have been added.
I've tried:
tags: ["Tag1, Tag2, Tag3"]
tags: ["Tag1","Tag2","Tag4"]
tags: "Tag1, Tag2, Tag3"
tags: "[\"Tag1\", \"Tag2\", \"Tag3\"]"
Nothing seems to take and I don't get any error messages, except for the bottom one.
Any help is appreciated.
Solved! Go to the solution
This is an accepted solution.
Problem was related to Metafields and not tags at all. The problem was I was not passing the ID of the metafield so it thought I wanted to create the same metafield over and over again, instead of getting an error message it just ignores updating the entire object.
This is an accepted solution.
Problem was related to Metafields and not tags at all. The problem was I was not passing the ID of the metafield so it thought I wanted to create the same metafield over and over again, instead of getting an error message it just ignores updating the entire object.