New Shopify Certification now available: Liquid Storefronts for Theme Developers

Set the "available" inventory through the graphQl api

JeremiahClaspel
Shopify Partner
1 0 1

Hello, 

 

I am trying to figure out how to set the "available" inventory through the GraphQL api and have been struggling to find a decent solution. The reason why I need the ability to set the "available" inventory, rather than the "onHand" inventory, is because we well the same product across multiple listings within bundles. This means that whenever we sell a product on one listing, we need the available inventory to be adjusted on all listings. 

 

If I use the inventorySetOnHandQuantities mutation, the available inventory will end up accounting for up to 2x the committed inventory because my proprietary software accounts for the committed inventory (globally across all product listings that include the component), and then Shopify accounts for what is committed for that listing. 

 

If I use any of the adjust quantity mutations, I would first have to get the available inventory for each listing, and then deduct the incoming change from that to get the difference and deduct that from the available inventory that I am trying to push. This can lead to some pretty awful performance when a single item may be listed across several dozen listings. 

 

Currently I am using the REST /inventory_levels/set.json endpoint, however that only allows for 1 item to be updated at a time, however it is also rather inefficient. I know there is the inventoryActive mutation, however that also only allows for 1 item to be updated per request. 

 

While updating 1 product per request via the REST option or the inventoryActive mutation, I am hoping to find a way of updating pages of items per request. With our order volume (x,000 orders per day)  and limited supply, some items will sell out in a matter of hours. This makes inventory updates critical to avoid over-selling while maintaining reasonable reserve inventory. 

 

Is there an option that I am not seeing? 

Reply 1 (1)
ShopifyDevSup
Shopify Staff
Shopify Staff
1203 190 420

Hey @JeremiahClaspel,

I've read through your post and understand that you're looking for a way to set the "available" inventory for a product that is sold across multiple listings within bundles using the Shopify GraphQL API. First, I recommend checking out this guide on building inventory management apps, which covers best practices and insights to help you better understand how inventory works on Shopify.


For the GraphQL solution you are exploring, you mentioned using the inventoryAdjustQuantity mutation, which requires obtaining the current inventory level before making changes. While this is a valid approach, it does come with some of the limitations outlined in your post. An alternative solution is to use the inventoryBulkAdjustQuantityAtLocation mutation instead, which offers more granularity by allowing you to use the availableDelta instead of setting an absolute value. This approach may be less time-consuming than consistently changing absolute values.


For processes that are not time-sensitive, using bulk operations (GraphQL) and leveraging webhook data can be an efficient approach to managing inventory. Bulk operations enable multiple operations to be set and run asynchronously without rate limiting, allowing you to retrieve and update inventory levels for multiple products in a single request. Using both the bulkQuery and bulkMutation operations can improve performance and reduce the number of API calls needed. Additionally, if you pair bulk operations with webhooks, you can automate the inventory management process further. When used in conjunction, these tools can help to build automated reconciliation tasks, especially helpful for businesses that sell products across multiple channels.

Hopefully this gives a few ideas to explore further!

Cheers,
@awwdam - Shopify Developer Support


 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog