我使用 cURL,而不是 github 库。 我有下一个代码
$query = <<<GRAPHQL
mutation InventorySet(\$input: [InventorySetQuantitiesInput!]!)
{
inventorySetQuantities(input: \$input) {
inventoryAdjustmentGroup {
createdAt
reason
changes {
name
delta
}
}
userErrors {
field
message
}
}
}";
GRAPHQL;
$variables = [
'input' => [
'name' => 'available',
'quantities' => [
'inventoryItemId' => $inventoryItemId,
'locationId' => $locationId,
'quantity' => $newQuantity
],
'reason' => 'correction'
]
];
return $this->makeGraphQLRequest($query, $variables);
为什么我会收到错误消息
syntax error, unexpected invalid token ("\"") at [33, 2]
请帮忙
代码中的错误说明和修复内容
请用此替换您的查询,并且在变量中您需要添加一个键“compareQuantity”,其值将是现有产品的可用数量,例如:0、1、2 等。
mutation InventorySet($input: InventorySetQuantitiesInput!) {
inventorySetQuantities(input: $input) {
inventoryAdjustmentGroup {
createdAt
reason
changes {
name
delta
}
}
userErrors {
field
message
}
}
}
$variables = [
'input' => [
'name' => 'available',
'quantities' => [
'inventoryItemId' => $inventoryItemId,
'locationId' => $locationId,
'quantity' => $newQuantity,
'compareQuantity'=> 1
],
'reason' => 'correction'
]
];