Inventory Level ID

Can anyone help me on how to find the InventoryLevel ID and ItemVariant ID on Shopify ?

This is to work on an integration to update the stock inventory on Shopify using InventoryLevels API.

1 Like

This does not seem possible (at least for the InventoryItem) and is most likely an error in the GraphQL-Specification:

Here is the GraphQL-Spec including an example (but there is no way to retrieve the ID):
https://shopify.dev/api/admin-graphql/2022-04/queries/inventoryLevel

The REST-API with the respective GET request states that inventory_level_ids and location_ids need to be provided:
https://shopify.dev/api/admin-rest/2022-04/resources/inventorylevel#get-inventory-levels

But there is no possibility in the GraphQL-API…

An InventoryLevel really has a compound primary key: the location_id and the inventory_item_id

So I think that this is a bug in the GraphQL-API

if you want get inv Level Id and locations by GraphQL, you can get it by product variant request:

variants(first:10){
                    edges {
                        node {
                        inventoryItem{
                            inventoryLevels(first:2) {edges {node {id location {id}}}}
                            }
                        }
                    }   
                }

Below is the query I used to get inventoryLevelId for a product.

The product for which I wanted to get inventoryLevelId was just the main product with no variants

So first I listed down the product Variants using the below query

query {
  productVariants(first: 10) {
    edges {
      node {
        id
        displayName
      }
    }
  }
}

and then used the productVariant Id of one of the products to get its inventoryLevelId

query {
  productVariant(id: "gid://shopify/ProductVariant/40766402265165") {
    id
    title
    inventoryItem {
      id
      inventoryLevels(first: 10) {
        edges {
          node {
            id
            location {
              id
              name
            }
          }
        }
      }
    }
  }
}
1 Like