Goal: retrieve all ACTIVE and PUBLISHED products for a specific collection in a single GraphQL query.
Key points and timeline:
Initial limitation: The Collection.products connection lacks filters for status/published_status, so a single-query solution wasn’t available. Internal feedback was submitted to add such filters.
Workarounds shared: Query the collection and fetch products (up to 250) then filter client-side (e.g., LINQ). Caveats: may return DRAFT items if they appear first; doesn’t inherently enforce ACTIVE or PUBLISHED filters server-side.
Latest update (partial solution):
Use productVariants with server-side filters: productVariants(query: “collection:{numeric-collection-id} product_status:active” …). Note: use product_status:active (not status:ACTIVE), and pass the collection’s numeric ID (not gid). This returns variants and includes parent product info.
Remaining gaps:
PUBLISHED filter: No confirmed way in this thread to also filter by published_status:published within the same productVariants query. Original requirement (ACTIVE + PUBLISHED) is only partially solved.
Status: Partially resolved; server-side filtering for ACTIVE via productVariants works, but handling published_status remains open.
Summarized with AI on December 27.
AI used: gpt-5.
Thanks for your post. Currently there’s not a built in way to achieve that in a single query so we’ve submitted some feedback about it internally, particularly around having some more filters in the Collection.products connection.
It’s true, but I am using C#, and because of that I can just use LINQ to filter the returned data super quick.
Don’t know what technology you are using, but maybe it has something similar
This should be possible now by using the productVariants graphql query.
For example:
query getProductVariantsByCollection {
productVariants(query:"collection:{your-collection-id} status:ACTIVE" first:10) {
nodes {
id
sku
product {
title
}
}
}
}
This will give you all of the active products for a specific collection id. The collection id you send in is just the number and not the gid. Hope this helps.