Multiple Names for Inventory Level Quantities

Hi,

I’m trying to query for multiple Inventory Level quantities as per your docs and encountering some strange behaviour. Querying with just one name (formatted as either “name” or [“name”]) returns an array of filtered results as expected. Querying for multiple names returns nothing. It feels like an AND operator is being applied internally to those params, when it should be an OR.

For reference: https://shopify.dev/docs/api/admin-graphql/2024-10/queries/inventoryLevel

Any insights into whether this is a bug or I’m doing something wrong?

Hi JRM,

Can you share the full query you’re trying?

Sure. This returns results:

query {
  inventoryLevel(id: "some-id") {
    quantities(names: ["available"]) {
      id
      name
      quantity
      updatedAt
    }
  }
}

This returns nothing (not even available):

query {
  inventoryLevel(id: "some-id") {
    quantities(names: ["available", "incoming"]) {
      id
      name
      quantity
      updatedAt
    }
  }
}

@Liam-Shopify my guess is that is a bug. Based on the example code displayed here that should return results right?

@JRM Could you check the product you are querying has inventory tracked by Shopify?

I’ve just tried this and it seems to work correctly for me

query {
  inventoryLevel(id: "gid://shopify/InventoryLevel/108261507297?inventory_item_id=45220062789857") {
    quantities(names: ["available", "incoming"]) {
      id
      name
      quantity
      updatedAt
    }
  }
}

And the response

{
  "data": {
    "inventoryLevel": {
      "quantities": [
        {
          "id": "gid://shopify/InventoryQuantity/108261507297?inventory_item_id=45220062789857&name=available",
          "name": "available",
          "quantity": 0,
          "updatedAt": "2024-10-26T11:52:51Z"
        },
        {
          "id": "gid://shopify/InventoryQuantity/108261507297?inventory_item_id=45220062789857&name=incoming",
          "name": "incoming",
          "quantity": 0,
          "updatedAt": null
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 2,
      "actualQueryCost": 2,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1998,
        "restoreRate": 100
      }
    }
  }
}

I tried again with a more careful eye on the available inventory states: Requesting available and incoming alongside each other does, indeed work, so this was my bad. Adding on_hold will lead to empty results. (Likewise for requesting various combinations of unavailable.)

Thank you. Solved.

1 Like