Hi, i am constructing a query string from a selection of collections and am using it in a productVariants GraphQL request.
product_status:active AND (collection:683553128793 OR
collection:683553096025 OR collection:683553063257 OR collection:683553030489
...
collection:683552670041 OR collection:683552637273 OR collection:683552604505)
Based on the docs, the syntax is valid query syntax, but i noticed, that it returns fewer variants than it should. Is there a limitation of complexity? Any ideas what could be the problem here?
What kind of collections are you querying under? Are they automated collections that use rules to match products to the collection? If so, what are the rules?
i have tried with different kinds of collections now. Manual collections seem to work fine with the query, rule based collections return fewer variants than they should.
For example, a collection with these rules returned 46 instead of 96 variants
Product tag is equal to candle
Product type is not equal to 23p_po_generated
Unfortunately the Shopify productVariants admin graphQL endpoint has been known to be unreliable for several years now, and Shopify has been unable to fix it. I have raised the issue probably at least 20 times between slack messages, bug reports, and this forum over the past 5 years.
Thanks for the info. Did you find an alternative endpoint that is more reliable?
Otherwise, the only option i see is to use a bulk query and keep a copy in my own database, which i try to avoid.
There is no workaround AFAIK. A Shopify staff member may come in ask you to first query the products and then nest the variants under instead of querying the variants directly, but that approach has many issues as I shared in the thread I have linked.
When the Shopify API does not work correctly, there is no alternative to downloading every variant in the store and then filtering or querying the correct variants yourself.
I can confirm that this is something that our developers are aware of at this time, and are currently looking into fixing further.
While I can’t share any estimated timeframes for a resolution, I can assure you that we have increased the priority on this behaviour and are actively investigating further.
To aid our developers investigation, can I ask for a specific example with the following details from an API call returning unexpected behaviour?
The full plain text HTTP Request, including URL, Body, and Headers (no access tokens)
The full plain text HTTP Response, including Body and Headers
Specific examples of product variants that you expect to be returned but are not
I can’t speak for Marcel but in this thread I have already provided a specific example of how the API is working incorrectly, complete with the exact query that was run, a request ID, and evidence supporting why the API is clearly not working correctly: productVariants GraphQL endpoint incorrect results
I did review that thread and do see that the examples were shared with our developers internally, however we do have a 30 day data retention period with our internal logs for api calls such as these, and I was hoping to get some recent examples to aid our developers furthers, as well as details on some specific products that you expected to be included in the api response but was not.
Example request ID: 825b17cc-bed7-491f-8967-fb85edf644c4-1766176160
Graph QL query:
{
productVariants(
first: 5
query: "((collection:456523612401))"
sortKey: ID
) {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
cursor
node {
title
id
price
compareAtPrice
product {
title
id
tags
vendor
productType
featuredImage {
altText
transformedSrc(maxWidth: 80)
}
}
inventoryItem {
unitCost {
amount
}
}
}
}
}
}
The Shopify web servers returns a response with 0 edges, while the collection has 39 products. This is not logically possible and is a clear indication that the API is not working correctly.
If you also want an example of a missing product variant ID, I have done some work to find one for you. It’s fairly easy to do this yourself as well, you can use a query like this:
Thank you very much for providing this recent example, I’ve shared this with our developers internally as well to aid our investigation in this behaviour.
In the meantime (cc: @marcel), I am going to close this thread out, as we do have the other thread active still and we can use that for further updates on the issue as they come.
Thanks Kellan. One tip that I might share for the team looking into this - don’t be afraid to retry the query yourself as you investigate. This is purely a read operation so retrying the query will not negatively impact the merchant in any way.
By testing the query yourself instead of asking for a new one every 30 days, that may help empower your team to better investigate the issue beyond the very short 30 days retention window.
Otherwise, the 30 day limitation means that the team must complete their investigation within 2 standard sprint cycles (assuming Shopify uses 2 week sprint periods) of when the bug is reported which I know may not always be possible.
We can’t discuss particulars about specific stores in the Community Forums, as we are unauthenticated with these stores here, but I can assure you that the context you’ve shared has been replicated and will be used to help further the investigation.
Thanks for investigating! I will provide an example from a dev shop in the next two days as well. I will post it in the other thread, or should i provide it by DM/Mail?
We can continue discussion of this issue in the other thread as needed, as this is a duplicate thread so we’ll leave this closed for now.
I do see that you posted here already, I may also recommend sharing a specific x-request-id from an example api call to include in our internal investigations.