I have another productVariants graphQL bug to report.
Basically, the API will often return incorrect results. This can be for a variety of reasons, but the example I will share here is for an automated collections that make extensive use of title contains or title not contains logic. This isn’t rare though, a lot of Shopify merchants like to do that.
Store ID: 28295626845
Collection ID: 306706251925
Request ID: 5e97dc9c-0c29-4dc9-a6a8-806de1f50a80-1745463602
First, try the REST API to check the product count on the collection:
/admin/collections/306706251925.json
The products_count key returns 127, which I believe is correct.
Next, try to fetch the variants with the productVariants graphQL query:
Hey again @Chris_Geelhoed - thanks for reporting this here. I think I was able to replicate this internally on my end here. If I run something like this though, it does look like I retrieve a lot more variants (I think it should be over 300+):
{
products(first: 250, query:"collection_id:306706251925") {
nodes {
id
inCollection (id:"gid://shopify/Collection/306706251925")
variants (first:100) {
nodes {
id
title
}
}
}
}
}
I’ll do some more digging into this on my end here and loop back when I have next steps/more info to share - thanks for flagging this!
Thanks for getting back to me @Liam-Shopify If there is any question about the priority of this bug, I would advocate for high priority as this bug can have a very negative impact on merchants, to the point where they are so upset that they not only uninstall apps but may leave 1 star reviews
@Alan_G I appreciate the idea but that does not work because the query now has nested edges which results in an extremely high query cost. On top of that we should not assume that a product can only have 100 variants, soon that will not be true.
Also, that query does not give the same results in many cases and using it will lead to other bugs. Here is a concrete example:
Merchant has products that have multiple variants. Let’s say a product has 3 variants priced at $5, $12, and $20 for different sizes.
Merchant creates an automated collection which includes all product variants under $10
Merchant uses an app to perform some action on all items in that collection
Using the suggested queries all 3 variants are included in the results, which is certainly not correct
I appreciate the help on this, but want to make it clear that there is no workaround here for app developers.
Hey @Chris_Geelhoed - thanks for the followups here, really appreciated. Like Liam mentioned, we still can’t guarantee a turnaround time on a resolution, but I’m going to pass along your feedback on the impact you’re seeing internally since I do realize that it’s having a negative merchant impact.
Would you have an app ID handy for your app so that I can take a look on my end here and pass along the specifics to the team as well? Just want to make sure we’re tracking the issue as best we can for you here. Hope to hear from you soon and thanks again for flagging this.
I’m having this issue come up again with another merchant. Info as following:
Store ID: 65294500074
Collection ID: 65294500074
Example Request ID: 36740213-806c-4871-bb97-895ecf4e3e7b-1763846914
Once again the collection has products in it, but when I run the query above (with the collection ID above) your server is responding with an empty list of edges which is incorrect
Thanks @Liam-Shopify If there is no update, would it be possible to share why this has not been looked into after such a long time? I feel that if your API is blatantly returning incorrect information, that should be considered important.
I have another angry merchant and API bug to report as well. This time the API is returning a nonsense response where the edges array is empty empty but hasNextPage is true, which should never happen.
Here is a JSON dump of the bug details including the query that was used and the nonsense response from the Shopify API server.
Nothing specific to share on why this bug still exists, it is in our backlog to address. Could you create a separate topic for the other bug you’ve reported?
@Liam-Shopify Would it be possible to move the task from the backlog to an upcoming sprint? It is important that the Shopify API returns the correct information. If the API is returning information that is incorrect how can app developers build apps, and how can merchants trust Shopify’s app ecosystem?
I have another merchant facing this issue today and this is severely affecting their BFCM. Another issue related to inconsistent results when querying the product variants in a collection:
Shop ID: 60579086577
Collection ID: 456522203377
Even if you can do something like correct a stale cache for that particular merchant, we would appreciate it
Me and the merchants using my app are facing this problem too. Would really appreciate if this could be fixed soon.
As described by @Chris_Geelhoed , the amount of variants that are returned are different with each request and generally lower than the actual amount.