Can anyone tell me why, when making a bulk product query, requesting products with all statuses (ACTIVE,ARCHIVED,DRAFT) only shows ACTIVE products?
If I change the status to ARCHIVED,DRAFT I get products with those statuses as expected. If I exclude the status query, I only get ACTIVE. I want all statuses and can’t seem to make it work. Here’s my query:
mutation {
bulkOperationRunQuery(
query: """
{
products(
sortKey: PUBLISHED_AT
reverse: true
query: "status:ACTIVE,ARCHIVED,DRAFT"
) {
edges {
node {
id
variants(first: 50) {
edges {
node {
image {
url(transform: {preferredContentType: PNG, maxWidth: 400})
}
title
price
product {
id
status
title
}
sku
inventoryQuantity
}
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
Similarly,
query: "status:ARCHIVED OR status:DRAFT"
works okay but
query: "status:ARCHIVED OR status:DRAFT OR status:ACTIVE"
does not
Thanks!
If you do a non-bulk query does it return what you expect? Also, if you try this simplified bulk query does it work:
mutation {
bulkOperationRunQuery(
query: """
{
products(query: "status:ARCHIVED OR status:DRAFT OR status:ACTIVE") {
edges {
node {
id
title
status
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
1 Like
Hi @Liam-Shopify , thanks for your response:
- Non-bulk version returns what I expect
- Your simplified bulk query also works as I would expect
If you add back in parts of your original query, at what point are you seeing just active products returned?
2 Likes
Okay following your advice, starting from your query I’ve added back piece by piece and it’s worked the whole time. I’m still not sure where the initial issue is - but I’m happy to be sorted now!
Thanks Liam
1 Like
In fact, the one thing that I’ve removed from the query is the sortKey and reverse attributes. Adding them back in as before once again removes ARCHIVED and DRAFT orders from the results. Solved!
1 Like
Great to hear this is working as expected now - will make a note about the sortKey and reverse attributes.
1 Like
You can simply remove the query: “status:ACTIVE,ARCHIVED,DRAFT”.
This will return products with all three statuses.
1 Like
Hi Merchbees, you’re absolutely right - without the sortKey / reverse attributes, there’s no longer any need to specify status and it will return all without a query. It was my mistake trying to use them in the first place.
Thanks
I mean the product has three statuses. If you need all three statuses as in your first message, you don’t need to specify it in your query. You can use sort and other options as you wish.
Hey, yeah I understood - but see my solution and issue below:
So the status doesn’t need specified as - but the other attributes need to be removed or only ACTIVE will be returned.
Hey @michaelchalmers,
I saw your solution but your conclusion doesn’t feel right to me.
Just for the reference for future readers: The query below returns “active”, “archived” and “draft” products.
In addition to that your initial query in your first message including
query: "status:ACTIVE,ARCHIVED,DRAFT"
return the products with all the statuses for my dev store.
mutation {
bulkOperationRunQuery(
query: """
{
products(
sortKey: PUBLISHED_AT
reverse: true
) {
edges {
node {
id
variants(first: 50) {
edges {
node {
image {
url(transform: {preferredContentType: PNG, maxWidth: 400})
}
title
price
product {
id
status
title
}
sku
inventoryQuantity
}
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
I understand it’s supposed to work this way, which is why I wrote the query as I did initially - however it was only returning ACTIVE, hence my post. We are exporting and comparing the data (~2000 vs ~3000 variants) so I’m not sure it’s the volume or what the issue is, but using or removing the product query attributes clearly changes the data returned.