A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I am trying to add Metafields to a newly created Product Image through either the privateMetafieldUpsert or the metafieldsSet mutations. The privateMetafieldUpsert mutation returns a "the owner record does not exist" error on the "input" field while the metafieldsSet mutation returns an "invalid id" error with locations "line":5,"column":31 and path "metafieldsSet". Here are the mutation queries being used:
mutation upsertPrivateMetafield($privateMetafield: PrivateMetafieldInput!) {
privateMetafieldUpsert(input: $privateMetafield) {
privateMetafield {
id
namespace
value
key
}
userErrors {
field
message
}
}
}
//--- variables
"variables": {
"privateMetafield": {
"key": "spImageTag",
"namespace": "SP",
"owner": "gid://shopify/ProductImage/29576762327118",
"valueInput": {
"value": "part.supplementfacts.img",
"valueType": "STRING"
}
}
}
mutation setMetafields($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
key
namespace
}
userErrors {
message
field
}
}
}
//--- variables
"variables": {
"metafields": [
{
"key": "spImageTag",
"value": "part.bottle.img",
"type": "single_line_text_field",
"namespace": "SP",
"ownerId": "gid://shopify/ProductImage/29577150365774"
},
{
"key": "spImageTag",
"value": "part.supplementfacts.img",
"type": "single_line_text_field",
"namespace": "SP",
"ownerId": "gid://shopify/ProductImage/29577150398542"
},
{
"key": "spImageTag",
"value": "part.bottle.img",
"type": "single_line_text_field",
"namespace": "SP",
"ownerId": "gid://shopify/ProductImage/29577150300238"
}
]
}
I've added in a call immediately prior to the mutation calls for the metafields and I can verify those ProductImages exist and that the Ids match.
Try with newer api versions, I'd the same issues with company gid and using 2023-01 api version I make my day!