GraphQL Query String Does Not Work with Multiple List Terms

I’m running into something when posting queries to the productVariants graphql Query and I can’t tell if this is a bug or if I’m just missing something in the docs.

I have 2 products (fake ids for the purpose of this post):
Product1:

id: 123456789

status: active

variants: 3

Product2:

id:987654321

status:draft

variants:1

When I post my Query I can use the query string option with a list of product_status like so:

productVariants(query: "product_status:active,draft", first:100)

This query works just fine and returns the expected results (4 product variants).

I can also post a query string with a list of product_ids like so:

productVariants(query: "product_ids:123456789,987654321", first:100)

This query also works just fine, and it also returns the expected results (4 product variants).

However, if I post a query string using both filters like so:

productVariants(query: "product_status:active,draft AND product_ids:123456789,987654321", first:100)

The query returns a 200 response with 0 results.

If I break the query string up into individual filters and group them like this:

productVariants(query: "(product_status:active OR product_status:draft) 
AND (product_id:6789058920620 OR product_id:6789095719084)", first:100)

The query once again returns the expected results (4 product variants).

Is there something I’m missing about why those two filters (and potentially other filters that accept lists of values) won’t work together in the shorter, more concise version of the query? This isn’t a blocker since I have a workaround (as demonstrated in the final example above) but it made me curious. I didn’t see anything in the “Shopify API Search Syntax” docs that would indicate you can’t use multiple list filters in a query, but perhaps I missed something somewhere?

Thanks for the quick reply, but the logic used in your response doesn’t really explain the behavior of the API

You said:

"The query is effectively looking for product variants that have both

product_status of active or draft

and

product_id of 123456789 or 987654321."

In other words:

product_status: active OR draft

AND

product_id: 123456789 OR 987654321

Both example products I listed will meet that criteria:

Product1:

product_status: active OR draft → true, status is ‘active’

product_id: 123456789 OR 987654321 → true, id is 123456789

result: true (product_status) AND true (product_id) → true

Product2:

product_status: active OR draft → true, status is ‘draft’

product_id: 123456789 OR 987654321 → true, id is 987654321

result: true (product_status) AND true (product_id) → true