【发布时间】:2021-10-05 14:48:51
【问题描述】:
我正在关注 GraphQL documentation for `productCreate,但我不知道如何在创建产品时添加多个变体。
我正在使用以下突变:
mutation productCreate($input: ProductInput!) {
productCreate(input: $input) {
userErrors {
field
message
}
shop {
id
}
product {
title
handle
variants {
edges {
node {
title
}
}
}
}
}
}
并传递以下变量:
{
"input": {
"title": "Testing Products",
"handle": "test-product-2",
"variants": [
{ "title": "Variant 1" },
{ "title": "Variant 2" }
]
}
}
我得到的错误是:
{
"data": {
"productCreate": {
"userErrors": [
{
"field": [
"variants",
"1"
],
"message": "The variant 'Default Title' already exists."
}
],
"shop": {
"id": "gid://shopify/Shop/59898691733"
},
"product": null
}
},
"extensions": {
"cost": {
"requestedQueryCost": 12,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 990,
"restoreRate": 50
}
}
}
}
我搜索了互联网,试图弄清楚如何在 Shopify 上创建产品时添加多个变体,但我无法弄清楚。
可以这样做吗?
【问题讨论】: