gnikyt / Basic-Shopify-API

A simple API wrapper for Shopify using Guzzle for REST and GraphQL
MIT License
220 stars 66 forks source link

Problem with GraphQL and multiple mutations #130

Closed kalitk0 closed 2 years ago

kalitk0 commented 2 years ago

I am trying to make two mutations with a single call but it returns an error, however, the same code is working with [Shopify GraphiQL App]

Here is the code:

mutation batchProductUpdates(
    $positions: [ProductVariantPositionInput!]! $id: ID!
    $moves: [MoveInput!]!
 ) 
{
    productVariantsBulkReorder(positions: $positions, productId: $id) {
        userErrors {
           field
           message
        }
    }
    productReorderImages(id: $id, moves: $moves) {
        userErrors {
            field
            message
        }
    }
}

Here is the error:

{
  "response": {},
  "body": [
    {
      "message": "ProductVariantPositionInput isn't a defined input type (on $positions)",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "mutation batchProductUpdates"
      ],
      "extensions": {
        "code": "variableRequiresValidType",
        "typeName": "ProductVariantPositionInput",
        "variableName": "positions1"
      }
    },
    {
      "message": "Field 'productVariantsBulkReorder' doesn't exist on type 'Mutation'",
      "locations": [
        {
          "line": 8,
          "column": 3
        }
      ],
      "path": [
        "mutation batchProductUpdates",
        "productVariantsBulkReorder"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Mutation",
        "fieldName": "productVariantsBulkReorder"
      }
    },
    {
      "message": "Variable $positions is declared by batchProductUpdates but not used",
      "locations": [
        {
          "line": 1,
          "column": 1
        }
      ],
      "path": [
        "mutation batchProductUpdates"
      ],
      "extensions": {
        "code": "variableNotUsed",
        "variableName": "positions"
      }
    }
  ],
  "errors": true,
  "timestamps": [
    null,
    1646299334.668582
  ]
}
kalitk0 commented 2 years ago

I was using older version of the API it is working with the latest one