如何使用Shopify Graphql ProductVariantsBulkInput
我试图一次批量更新多个产品变体的价格 我所做的只是复制粘贴代码,然后输入我自己的id。当然,这是行不通的 看起来是这样的:如何使用Shopify Graphql ProductVariantsBulkInput,graphql,shopify,shopify-api,Graphql,Shopify,Shopify Api,我试图一次批量更新多个产品变体的价格 我所做的只是复制粘贴代码,然后输入我自己的id。当然,这是行不通的 看起来是这样的: mutation productVariantsBulkUpdate($variants: [ProductVariantsBulkInput!]!, $productId: ID!) { productVariantsBulkUpdate(variants: $variants, productId: $productId) { product {
mutation productVariantsBulkUpdate($variants: [ProductVariantsBulkInput!]!, $productId: ID!) {
productVariantsBulkUpdate(variants: $variants, productId: $productId) {
product {
cursor
}
productVariants {
cursor
}
userErrors {
code
field
message
}
}
}
{
"variants": [
{
id: "gid://shopify/ProductVariant/39369514385591",
price: "50.00"
}
],
"productId": "gid://shopify/Product/6591908577463"
}
使用如下变量:
mutation productVariantsBulkUpdate($variants: [ProductVariantsBulkInput!]!, $productId: ID!) {
productVariantsBulkUpdate(variants: $variants, productId: $productId) {
product {
cursor
}
productVariants {
cursor
}
userErrors {
code
field
message
}
}
}
{
"variants": [
{
id: "gid://shopify/ProductVariant/39369514385591",
price: "50.00"
}
],
"productId": "gid://shopify/Product/6591908577463"
}
我得到了这个错误:
变量是无效的JSON:JSON中的意外标记i位于位置30。
对我来说没问题。(进行了一些快速调整)
由于产品/变体对象中不存在光标
,我对请求进行了一些调整,不知道Shopify为什么没有在他们的文档中更新示例
mutation productVariantsBulkUpdate($variants: [ProductVariantsBulkInput!]!, $productId: ID!) {
productVariantsBulkUpdate(variants: $variants, productId: $productId) {
product {
id
}
productVariants {
id
price
}
userErrors {
code
field
message
}
}
}
因此,请尝试修复查询并删除游标
对象,并检查您是否使用了正确的端点,因为只有在我没有弄错的情况下,批量操作才能在不稳定的版本中使用
请参阅下面的图片,显示我的回答是正确的
是的,你在所有方面都是对的!另外,只有不稳定的API版本支持这一点。