Bulk Adjustment API Not adding/connecting new Inventory Levels

rkazokas
Tourist
5 0 3

I want to preface this with I do not have any fulfillment service locations set up. We started out with a single location(non legacy) in our Shopify store, then created all of our products/variants. In our app we are using the inventoryBulkAdjustQuantityAtLocation API and it is working for that single location. All of our items are tracked by shopify with manual fulfillment services.
However when I created a new location, i am unable to do the bulk adjustment without manually going into the UI and tracking at that given location OR using the adjustments/sets REST API. Why does the BulkAdjustmentAtLocation not connect an inventory item to a location but the rest API does?

REST API(This works) - https://xxxxx.myshopify.com/admin/inventory_levels/set

{
    "inventory_item_id": <inventoryITemId>,
    "location_id": <locationId>,
    "available": 45
}




 

GraphQL API(This doesn't work) - https://xxxxxx.myshopify.com/admin/api/2020-01/graphql.json

 

mutation{
  inventoryBulkAdjustQuantityAtLocation(inventoryItemAdjustments:[
    {
      inventoryItemId:"gid://shopify/InventoryItem/<InventoryItemId>",
      availableDelta:45
    }
  ],
    locationId:"gid://shopify/Location/<LocationId>"){
    userErrors{
      message,
      field
    },
    inventoryLevels{
      id,
      available,
      item{
        id,
        sku
      }
    }
  }
}

 

 

And returns this response:

 

{
  "data": {
    "inventoryBulkAdjustQuantityAtLocation": {
      "userErrors": [
        {
          "message": "Quantity couldn't be adjusted because this product isn't stocked at xxxxxx.",
          "field": [
            "inventoryItemAdjustments",
            "0",
            "inventoryItemId"
          ]
        }
      ],
      "inventoryLevels": null
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 11,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 1000.0,
        "currentlyAvailable": 990,
        "restoreRate": 50.0
      }
    }
  }
}

 

 

I have an API Request ID if needed.

 

 

hassain
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 135

Hey @rkazokas ,

 

The two functions you are comparing from the REST API and GraphQL API do different things:

 

The GraphQL inventoryBulkAdjustQuantityAtLocation, from the documentation, adjusts the inventory at a location for multiple inventory items. Per this definition, if the inventory is not already at the location then there will be nothing to adjust and therefore this mutation will not work. So the error message you are getting here for this mutation is correct and expected. https://shopify.dev/docs/admin-api/graphql/reference/mutation/inventorybulkadjustquantityatlocation?...

 

The REST "inventory_levels/set.json", from the documentation, sets the inventory level for an inventory item at a location. If the specified location is not connected, it will be automatically connected first. Per this definition, if the inventory is not already at the location then Shopify will automatically connect them first before setting the inventory quantity. So the successful response you are getting for this POST request is correct. https://shopify.dev/docs/admin-api/rest/reference/inventory/inventorylevel?api[version]=2020-01#set-...

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

rkazokas
Tourist
5 0 3

@hassain Thanks for the explanation on that. That wasn't initially obvious to me, but it makes sense. The docs seem to be more around when fulfillment service is involved. I didn't try the adjust endpoint in the rest api prior to this. I think what confused me was that the graphql API doesn't have a 'set' equivelent but what I think I am looking for would be this mutation:
https://shopify.dev/docs/admin-api/graphql/reference/mutation/inventoryactivate?api[version]=2020-01 for when we want to add inventory at a location. 

0 Likes