Trying to get all Quantities for Product in Store

I’m building an app that will allow us to transfer a product from available to one of the unavailable categories but first we just want to get quantities. I have some code that seems pretty simple but it doesn’t return anything. See below:

query ProductInventoryQuantities($productId: ID!, $locationId: ID!) {
  product(id: $productId) {
    id
    title
    variants(first: 100) {
      edges {
        node {
          id
          title
          sku
          inventoryItem {
            id
            inventoryLevel(locationId: $locationId) {
              quantities(names: ["unavailable", "on_hand", "committed"]) {
                name
                quantity
              }
              updatedAt
            }
          }
        }
      }
    }
  }
}

Inputting:

{
  "productId": "gid://shopify/Product/xxxxxxxxxx8624",
  "locationId": "gid://shopify/Location/xxxxxxx4304"
}

I’m not getting an error, just “null” and the cost info.

Any suggestions would be VERY welcome!

1 Like

Hey @RSL_IT :waving_hand: - hopefully I’m understanding correctly here, but you’re seeing a null array for the inventory quantity location based on the location ID you input there?

If so, I think the most likely reason for this would be if the location you’re querying is tied to a fulfillment app location. If the location is owned by a fulfillment service, and that fulfillment service manages inventory, then other API clients can’t access the inventory for that location.

Could you let me know if that’s the case there? If not, more than happy to keep digging into this with you!

Are you still seeing this issue @RSL_IT ?

My apologies. After further testing, I realized I was using the Inventory Item Id, not the Product ID I should have been using.

So, I did find the issue. I’m still getting my “GraphQL legs”…

Thanks for the response!

Scott.