カスタムアプリでStorefront API (API ver. 2022-10) のcheckoutCreate mutationを叩いているのですが、同じmutationを渡しても成功する場合と以下のエラーが返る場合があります。
{
"data": {
"checkoutCreate": {
"checkout": null,
"checkoutUserErrors": [
{
"field": [
"input",
"lineItems",
"0",
"variantId"
],
"message": "Variant 無効です"
},
{
"field": [
"input",
"lineItems",
"1",
"variantId"
],
"message": "Variant 無効です"
},
{
"field": [
"input",
"lineItems",
"2",
"variantId"
],
"message": "Variant 無効です"
}
]
}
}
}
このエラーが返った時に叩いたAPIは以下のコードによるものです。
axios.post(
`https://****.myshopify.com/api/2022-10/graphql.json`,
{
query: `
mutation {
checkoutCreate(input: {
lineItems: [{variantId: "gid://shopify/ProductVariant/********", quantity: 1}, {variantId: "gid://shopify/ProductVariant/********", quantity: 2}, {variantId: "gid://shopify/ProductVariant/********", quantity: 1}]
shippingAddress: {
zip: "*******",
country: "Japan",
province: "****",
city: "****",
address1: "****",
firstName: "****",
lastName: "****"
}
}) {
checkout {
id
webUrl
subtotalPrice {
amount
}
totalTax {
amount
}
taxesIncluded
availableShippingRates {
shippingRates {
handle
price {
amount
}
title
}
}
}
checkoutUserErrors {
field
message
}
}
}
`,
variables: {},
},
{
headers: {
"X-Shopify-Storefront-Access-Token": "****",
"Shopify-Storefront-Buyer-IP": "**.**.**.**",
"Content-Type": "application/json",
},
},
)
一方で、同じinputで同じmutationを叩いていてもエラーにならず、checkoutCreate.checkout.idを取得できる場合もあります。
考えられる原因や解決策がありましたら教えていただけますと幸いです。