Multiple Mutations in GraphQL, inventoryLevel and productVariantUpdate

Solved
Highlighted
Tourist
5 2 1

Is it possible to update inventoryLevel  and productVariantUpdate in one call?

 

Currently i am running two calls, one for the productVariantUpdate  and another for inventoryLevel,
I am struggling to merge the two together to reduce the call limit, Is this possible?

Example:

mutation 
productVariantUpdate($input: ProductVariantInput!) {
  productVariantUpdate(input: $input) {
    product {
      id
    }
    productVariant {
      id
      price
    }
    userErrors {
      field
      message
    }}}

Variables:

{
  "input": {
    "id": "gid://shopify/ProductVariant/99999999999",
    "price": 55
  }
}

 

And Inventory Level:

mutation inventoryActivate($inventoryItemId: ID!, $locationId: ID!, $available: Int) {
  inventoryActivate(inventoryItemId: $inventoryItemId, locationId: $locationId, available: $available) {
    inventoryLevel {
      id
      available
    }
    userErrors {
      field
      message
    }
  }
}

Variables:

{
  "inventoryItemId": "gid://shopify/InventoryItem/99999999999",
  "locationId": "gid://shopify/Location/8888888888",
  "available": 11
}
0 Likes
Highlighted
Tourist
5 2 1

This is an accepted solution.

To answer my own question, Yes its possible.

 

An example here would be:

 

mutation batchProductUpdates(
  $input: ProductVariantInput!
  $inventoryItemId: ID!
  $locationId: ID!
  $available: Int
) {
  
  productVariantUpdate(input: $input) {
    product { id }
    productVariant { id price }

  }
  
  inventoryActivate(
    inventoryItemId: $inventoryItemId
    locationId: $locationId
    available: $available
  ) {
    inventoryLevel { id available }
 
  }

}