How to Fix Inventorylevels code

Hi,

I downloaded a Flow Template (titled “Add free (discounted 100%) item to new orders”) with a query that isn’t functioning:

query{
getProductVariantData {
id
inventoryItem {
inventoryLevels {
available
location {
id
name
}
}
}
}
}

Available is apparently deprecated so I tried this instead, but it’s not running.

query{
getProductVariantData {
id
inventoryItem {
inventoryLevels(locationId: $locationId) {
quantities (names: “available”) {
quantity
name

                            }
                          }
                        }

Can anyone anyone advise on how to fix it?

To locate the variable, navigate to the “Deprecated” section at the bottom of the list. Expanding this section will reveal the variable you’re looking for. I think, shopify is currently developing a new method for accessing this variable, but it has not yet been finalized in Flow.

Hi, try this?

query GetProductVariant($id: ID!, $locationId: ID!) {
  productVariant(id: $id) {
    id
    title
    inventoryItem {
      inventoryLevels(locationId: $locationId) {
        quantities(names: ["available"]) {
          quantity
          name
        }
      }
    }
  }
}