[GraphQL] New Mutation for bulk inventory adjustment at a single location

Shopify Staff
Shopify Staff
469 36 92

Hey Devs,

 

To allow apps to sync inventory changes faster, we have just released a new inventoryBulkAdjustQuantityAtLocation GraphQL mutation.

This mutation has a cost of 10, and allows to adjust the inventory of up to 100 inventory items at a specific location. With the GraphQL bucket refill of 50 this allows adjusting inventory of up to 500 inventory items per second.

mutation {
  inventoryBulkAdjustQuantityAtLocation(
    locationId: "gid://shopify/Location/1",
    inventoryItemAdjustments: [
      {inventoryItemId: "gid://shopify/InventoryItem/1", availableDelta: 1},
      {inventoryItemId: "gid://shopify/InventoryItem/2", availableDelta: 10}
      ]) {

    inventoryLevels {
      available
    }
  }
}

Here's an example using Insomnia on my store:

With a sync bandwidth of 1.8M adjustments per hour, this should remove the need for Fulfillment Services to be the inventory manager; i.e. using the hourly fetch_stock sync. We recommend this mutation as the prefered way for Fulfillment Services to sync inventory changes with Shopify.

If you need help with GraphQL, you can join us in the #graphql channel of the Shopify Partners Slack!  Also check out our Getting Started Guide and Blog post on using GraphQL with Locations.  Our newest guides (fulfillment, inventory) also include GraphQL examples.

 

Happy Coding!

Developer Experience @ Shopify
0 Likes
Tourist
10 0 1

But this still requires us to call the stock level within Shopify first.... slow. We need you to allow us to SET the stock and ignore any adjusting like in the REST interface.

 

Dave

1 Like
Shopify Staff
Shopify Staff
469 36 92

Hi Dave,

There are no plans to include a set endpoint for the new inventory APIs.  You can keep track of any inventorylevel changes using webhooks and perform an adjust to the intended level.  Inventory sets were too racy when multiple actors are adjusting inventory and often resulted in incorrect inventory counts.

Ryan

Developer Experience @ Shopify
0 Likes
Shopify Partner
21 1 8

How do i get in on the Partner Slack Channel?

 

If you need help with GraphQL, you can join us in the #graphql channel of the Shopify Partners Slack!  Also check out our Getting Started Guide and Blog post on using GraphQL with Locations.  Our newest guides (fulfillmentinventory) also include GraphQL examples.

Metafields is a myth...
0 Likes
Shopify Partner
10 0 5

I'm going to chip in and say it would be great if we had a 'set'.

I certainly understand the race conditions, but I would imagine that a lot of your customers don't have stores where race conditions are a massive concern; assuming the inventory update are performed at slow times.

4 Likes
Shopify Staff
Shopify Staff
469 36 92

https://help.shopify.com/en/partners/getting-started/walkthrough#step-3-join-the-community

 

Link to join slack is on this page.

Developer Experience @ Shopify
0 Likes
Shopify Partner
21 1 8

Thanks Ryan

Metafields is a myth...
0 Likes
New Member
1 0 8

I wanted to chime in and again stress how great the ability to set would be here. I certainly understand race conditions can come up, but we have an enterprise level ERP system that is the master of iventory data across all our systems, and we periodiaclly run full syncs to keep things up to date.

 

Without the set, we have to query the current shopify number, and then go and set it. "inventoryBulkAdjustQuantityAtLocation" is great and is only about 10% of the overall sync time, but we are spending 90% of the sync time just querying the current shopify number so we can calculate a delta (this is actually leads to _more_ race condtions).

It would be an INCREDIBLE help to have the ability to set the inventory number, and we could get our full ERP sync down to less than half a minute. 

8 Likes