Hi,
We are trying to set the optionValues
, for a product variant where the optionValues
that are linked to a metafieldValue
, using the productVariantsBulkCreate
and/of productVariantsBulkUpdate
mutations, and we run into a confusing set of error messages.
Let’s try to update the optionValues
with a productVariantsBulkUpdate
mutation (for full mutation, see below), for a product option that is linked to a metafield value:
"optionValues": [
{
"optionName": "Color",
"name": "Red",
"linkedMetafieldValue": "gid://shopify/Metaobject/88683086037"
}
]
# error message: Cannot set name for an option value linked to a metafield
Ok, let’s remove the name
:
"optionValues": [
{
"optionName": "Color",
"linkedMetafieldValue": "gid://shopify/Metaobject/88683086037"
}
]
# error message: id or name must be specified
Ok… let’s try adding an id
instead of a name
then?
"optionValues": [
{
"optionName": "Color",
"id": "gid://shopify/ProductOptionValue/3540024983765",
"linkedMetafieldValue": "gid://shopify/Metaobject/88683086037"
}
]
# error message: Cannot set id for an option value linked to a metafield
Maybe I need to only provide a linkedMetafieldValue
?
"optionValues": [
{
"linkedMetafieldValue": "gid://shopify/Metaobject/88683086037"
}
]
# error message: optionId or optionName must be specified
As you can see, the error message seem to point in a circle. Which kind-off suggests that setting a linkedMetafieldValue
through the GraphQL API (version: 2025-04
) is not supported?!
Our question
How do we set the optionValue
for product options, that are linked to a metafield vale, using the productVariantsBulkCreate
and/of productVariantsBulkUpdate
mutations?
Thanks in advance!
For reference: full GraphQL mutation used:
// Mutation
mutation ($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkUpdate(productId: $productId, variants: $variants) {
product {
id
}
userErrors {
field
message
}
}
}
// Variables
{
"productId": "gid://shopify/Product/8902245974229",
"variants": [
{
"id": "gid://shopify/ProductVariant/51310185382101",
"optionValues": (... see above ...)
}
]
}
For reference: the following block will update the `optionValues` for a product option that is **not** linked to a metafield value, without error:
"optionValues": [
{
"optionName": "Style",
"name": "Fancy",
}
]
# Ok (no errors)