Hi there!,
I’m trying to create new products and variants using GraphQl. I’ve tried different approaches using the examples given by the Shopify docs but I received an error as output. These are the examples we’ve used and the error. Any ideas ?
What we are trying to do is create a product and all its variants. Is it possible ?
Thank you in advance
mutation productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
productVariantsBulkCreate(productId: $productId, variants: $variants) {
userErrors {
field
message
}
product {
id
options {
id
name
values
position
optionValues {
id
name
hasVariants
}
}
}
productVariants {
id
title
selectedOptions {
name
value
}
}
}
}
{
"productId": "gid://shopify/Product/8332936610007",
"variants": [
{
"optionValues": [
{
"name": "Red",
"optionName": "Color"
},
{
"name": "Brand new style",
"optionName": "Brand and Style"
},
{
"name": "Silk",
"optionName": "Material"
}
],
"price": 22
}
]
}
{
"errors": [
{
"message": "The option doesn't exist",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"productVariantsBulkCreate"
]
}
],
"data": {
"productVariantsBulkCreate": null
},
"extensions": {
"cost": {
"requestedQueryCost": 13,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1924,
"restoreRate": 100
}
}
}
We’re following the examples in this part of the docs: