Error: 'Field 'availableQuantity' doesn't exist on type 'InventoryLevel' in Shopify GraphQL API

I’m encountering an issue while using Shopify’s Admin API with GraphQL. When trying to query the inventory levels for a product variant, I get the following error: Field 'availableQuantity' doesn't exist on type 'InventoryLevel'. I am attempting to access the available stock for my product variants using the following query:

query getInventoryItem($productId: ID!) {
  product(id: $productId) {
    variants(first: 1) {
      edges {
        node {
          id
          inventoryItem {
            id
            inventoryLevels(first: 1) {
              edges {
                node {
                  id
                  availableQuantity  // <-- This is where the error occurs
                }
              }
            }
          }
        }
      }
    }
  }
}

Could you please clarify whether the field availableQuantity is still valid or if I need to use a different field to fetch available stock? Any guidance or documentation on the correct approach would be very helpful.
Thank you!"_

Hi, can you confirm where you have seen availableQuantity? I just checked the API, all the way back to 2024-04 and it doesn’t seem to be an available field.

It was available before (not availableQuantity) but with the 2024-04 - available and incoming are deprecated. You can use something like this:

query MyQuery {
  product(id: "") {
    variants(first: 10) {
      edges {
        node {
          inventoryItem {
            inventoryLevels(first: 10) {
              edges {
                node {
                  quantities(names: "available") {
                    name
                    quantity
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

You can also use array for the names field.
quantities(names: ["available", "incoming"])