Greetings
The graphql admin API appears to still have the limitation that one cannot query PUBLISHED products by a collection IN ORDER (in the order they appear on store/admin panel).
Products can be returned BY COLLECTION but they will either INCLUDE UNPUBLISHED products, or they will not be IN ORDER.
This is a limitation that the rest API did not have.
Yes we can paginate and manually filter unpublished products, but that is inefficient and could result in the first 250 products being unpublished as an edge case.
Yes we can manually store all products in our database and query there, but again it’s inefficient and cumbersome.
Yes there’s the storefront API but the resulting information doesn’t contain valuable product admin information.
Is there any solution to this problem that isn’t a hacky workaround to just query multiple times?
Wondering if there is any news or a solution to this limitation in the graphql api?
You actually don’t need to rely on pagination hacks or client-side filtering for this anymore.
The proper approach is to use the Admin GraphQL API with the published_status filter, so the filtering happens server-side before pagination is applied.
For example:
query {
products(
first: 250
query: "published_status:unpublished"
) {
edges {
node {
id
title
status
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
This avoids the edge case where the first 250 products might all be unpublished, because Shopify handles the filtering at the query level.
If you’re working with a specific channel, you can also do something like:
query: "published_status:online_store_channel-hidden"
A couple of important notes:
-
published_status is what you want for visibility (published/unpublished)
-
product_publication_status is different — it’s for channel workflow states (approved, scheduled, etc.)
-
publishable_status is deprecated and shouldn’t be used going forward
If you need more control per channel, you can fetch publication IDs first and use those in your query.
Overall, this is the cleanest and most efficient solution right now without needing to store products locally or run multiple queries.
Thank you for being a lone helper! Greatly appreciated!
The issue is that when using the “published” filter, it will still return products hidden from online store. Unless this has been somehow recently altered
Hi @James_Maroney Yes, you can query unpublished products by using published_status:unpublished
query products($first:Int,$queryStr: String){
products(first: $first,reverse: true, sortKey: UPDATED_AT, query: $queryStr) {
edges {
node {
id
title
publishedAt
}
}
pageInfo{
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}
variables:
{
"queryStr":"published_status:unpublished",
"first":10
}
Hi! Thanks again for chiming in. I think there’s some confusion, the problem is you can’t query for published products on the online store. Graphql still returns products that are unpublished on the online store