How to filter products in collection? GraphQL problem

Highlighted
Shopify Expert
4219 31 422

I have a smart collection I get by ID. I then see that it has 152 products. So I want to filter down those products. I use sortKey:BEST_SELLING which orders the products in the best selling order, and now I just want to see a subset of the products, based on their product type. The docs say I can write a query. I do that, and I get an access denied message.

 

What am doing wrong? Both of these queries fail... so it not a camel-case, snake-case thing... sigh... help?

 

    products(first: 50,sortKey:BEST_SELLING,query:"product_type:Tops") {

   products(first: 50,sortKey:BEST_SELLING,query:"productType:Tops") {

 

image

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Shopify Staff (Retired)
Shopify Staff (Retired)
624 102 127

Hey @HunkyBill ,

 

The "Access Denied" error you are seeing is not specific to the product_type query filter you are adding to the products resource, but rather it is because Shopify does not allow you to use the query argument in general to further filter the products resource within a collections node. This is a known and intentional limitation on Shopify's end. You can read more about this from these previous threads:

 

https://community.shopify.com/c/Shopify-APIs-SDKs/Graph-QL-Access-denied-Issue/td-p/572801

https://community.shopify.com/c/Shopify-APIs-SDKs/Getting-quot-access-denied-quot-when-querying-with... 

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

1 Like
Highlighted
Shopify Expert
4219 31 422

Yes. So who left that in the documentation as a thing we can do? Oh wait, I get it. The documentation is correct, the GraphQL is correct, but under the hood, Shopify is unable to service this due to infrastructure not actually being there today. And yes, now I know, that this is a known thing, and it has been known for over a year now, and that yes, Shopify is working on it, and that yes, this is coming soon, probably this summer 2020.

 

So I wasted some time, but I get it... all in the name of progress. Anyway, thanks for letting me know!

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes