-1

I use cURL, not a github library. I have a next code

$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);

why do i get the error syntax error, unexpected invalid token ("\"") at [33, 2]

Please help

Explanation of the error and what to fix in the code

1
  • 1
    There is one single location in that code that contains a double quote, }";. Commented Nov 27, 2024 at 14:58

1 Answer 1

1

Please replace your query with this and in the variable you need to add one more key "compareQuantity" and its value will be the existing product have the available quantity like: 0, 1, 2 etc.

        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'
          ]
        ];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.