A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hey there,
inventorySetOnHandQuantities is a great method allowing us to update 250 inventory items in one go.. great and thanks for that. The only problem is that the mutation is unfortunately an "all or nothing" mutation if for some reason a single inventoryitemid is not found the entire mutation block seems to fail e.g. nothing gets updated. This should be reported in the usererrors query indicating which line failed but the reset of the mutation shouldn't really fail in my opinion.
Could we get some kind of flag added so that we don't have the entire thing fail because a single item was not found?
Cheers,
Gary
Hi Gary,
Thanks for your feedback. I understand how having a more flexible approach to updating inventory could improve your workflow. At the moment, as you pointed out, the inventorySetOnHandQuantities
mutation is designed to be atomic - meaning it either fully succeeds or fails. This is intended to ensure data consistency.
I'll pass this feedback to our product team for consideration in future updates. We always appreciate hearing about ways we can improve our APIs to better suit your requirements.
In the meantime, you could implement some error checking on your end before sending the mutation request. For example, you could verify the existence of inventory item IDs before including them in the mutation.
Hope this helps,
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me 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
Hi Liam,
thanks for the reply and sorry for not getting back sooner.. things are a bit crazy right now as we ramp up for the holiday season.
I agree that in some circumstances making a batch of db updates as an atomic transaction to prevent data inconsistency makes sense.. when the purpose is to prevent data inconsitency. But in this particular case there is no threat of data inconsistency since the items that are to be updated no longer exist, hence no consistency issue would be created.
Your interim solution would work for a small customer with a couple hundred products/variants to update but this particular merchant has just over 25k items currently, which will probably double within the year, selling on 3 channels with a B2B shop running on another system, and POS's and the requirement to keep the Shopify inventory synched with a maximum of 30 minute cycle. So we all know in this situation that the the rest api is out, there is no way that I could make 25k rest api calls within a half hour even with a plus account without spawning multiple threads, so that leaves me with the graphql query.. and the need to ensure that the inventory_item_ids I have in our db all exist.. that means creating a job to check the items and adding a product/delete webhook.. (Would love a variant/delete webhook fyi). This over complicates things a bit.
I'll have to think about how to handle this.
cheers and thanks for the reply
Hi again Gary,
Could you share a request id for a mutation that failed, so we can see what validation is causing the bulk mutation to fail?
Cheers,
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me 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
Hey Liam,
Sure, I havent had a chance to clean the db yet so I will get that to you on Monday.
Cheers
Gary
Hi Liam,
I got that request id for you: 34d93c4d-4916-4604-baa3-7b9178c91a85
Cheers,
Gary