Inventory update with absolute value specification

Thank you for your help.
(Since I am in a situation where I cannot try GraphQL, I asked here)

I would like to update the stock quantity with an absolute number.
Is it possible with the following method?

Example: When updating the stock quantity from “10” to “15”

  1. The number of stock is “10”
  2. Disable once with “inventoryDeactivate”
  3. Activate again with “inventoryActivate” and specify “15” in “available”

Hello @tanakatanaka

Based on your description, it seems like you are referring to the Shopify GraphQL API for updating the stock quantity. The method you described involves deactivating and then activating the inventory with a specified available quantity.

Yes, it is possible to update the stock quantity using the method you mentioned. Here’s a general outline of how you can achieve this using the Shopify GraphQL API:

  1. Authenticate and make a GraphQL API request to retrieve the product variant ID and the current stock quantity.

  2. Use the inventoryActivate mutation to deactivate the inventory for the variant. This will temporarily remove it from the available stock.

  3. Use the inventoryAdjustQuantity mutation to adjust the stock quantity. Set the available field to the desired absolute number, in this case, “15”.

  4. Use the inventoryActivate mutation again to activate the inventory with the updated stock quantity.

Note that the specific syntax and implementation details may vary depending on the programming language and GraphQL client you are using. You’ll need to refer to the documentation of the Shopify GraphQL API and the client library you’re using for more specific instructions on how to construct the API requests.

Thanks