Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

query with more than one param doesnt work

nikhilyayloh
Shopify Partner
2 0 0

Hi, 

 

I am trying to fetch products which have positive inventory quantity among the list of product ids. 

But my query below does not return any results. 

{
        productVariants(first: 10, query: "(inventory_quantity:>0) AND (product_ids:7483474804973,7483550007533)") {
            edges {
                node {
                    id
                    image {
                        url
                    }
                    product{
                        id
                    }
                    availableForSale
                    inventoryQuantity
                    price
                    selectedOptions {
                        name
                        value
                    }
                }
            }
        }
        }

 

But if i would run the above query with either inventory condition or product_ids only, then i get results. 

What am i doing wrong here?

 

Big thanks for help.

Replies 4 (4)

Liam
Shopify Staff
2677 288 736

Hi Nikhilyayloh

 

Can you try:

query: "(inventoryQuantity:>'0') AND (product_ids:xxxx,xxxx)")

The above worked when I tested in the graphiql app.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

nikhilyayloh
Shopify Partner
2 0 0

Hi Liam, 

It might execute and give results but if you increase the inventory value from 0 to say 100K, you will see that it doesnt filter out data. So that condition itself is not used. Plus inventory_quantity is the query field mentioned in the documentation.

 

Liam
Shopify Staff
2677 288 736

I see what you mean - other filters like vendor appear to work as expected alongside product_ids but inventory_quantity is not - I'll dig into this a bit more.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Liam
Shopify Staff
2677 288 736

Hi Nikhilyayloh,

 

We've identified this is a bug on our side and will be shipping a fix asap.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog