Access denied on querystring

New Member
1 0 1

I am trying to filter a collection by product tags, but I am getting 'Access denied'.

 

It's strange because I can filter products:

 

query Smu {
 products(query:"title:Samsung Gear S3" first: 10) {
   edges {
     node {
       title
       tags
       collections(first: 10) {
         edges {
           node {
             handle
             title
           }
         }
       }
     }
   }
 }
}

As I mentioned, the above query works and I get all products named Samsung Gear S3

 

 

But when I try to filter the same in Collection: 

 

query Bar {
 collection(id: "gid://shopify/Collection/88417960009") {
   products(query:"title:Samsung Gear S3" first: 10) {
     edges {
       node {
         title
         productType
       }
     }
   }
 }
}

It returns

 

{
 "data": {
   "collection": null
 },
 "errors": [
   {
     "message": "access denied",
     "locations": [
       {
         "line": 18,
         "column": 5
       }
     ],
     "path": [
       "collection",
       "products"
     ]
   }
 ],
 "extensions": {
   "cost": {
     "requestedQueryCost": 13,
     "actualQueryCost": 1,
     "throttleStatus": {
       "maximumAvailable": 1000,
       "currentlyAvailable": 999,
       "restoreRate": 50
     }
   }
 }
}

 

 

Why could this be happening?

 

Best regards

 

 

1 Like
Highlighted
Shopify Partner
1838 174 624

Hmm, couldn't reproduce that exact error you are getting.

 

I am getting this one instead

 

 

"errors": [
    {
      "message": "Cannot filter by query if the collection is a custom collection.",
      ...
    }
]

 

 

Which is fair enough. Just an API constraint.

 

One way to sort of workaround this is to simply query products with a query filter on title as you have and use the inCollection field then have the response filtered on your side.

 

 

{
  products(query:"title:Samsung Gear S3" first: 10) {
    edges {
      node {
        title
        productType
        inCollection(id: "gid://shopify/Collection/<COLLECTION_ID>")
      }
    }
  }
}

 

Hope this helps!

 

I turn coffee in to code - since 1998
0 Likes
Highlighted
Shopify Partner
50 0 9

Hi All,

 

I'm running into this as well but my understanding from @Alex is that it's not supported at the moment. Perhaps in the future.

 

@Alex any updates on support for this? If it's not coming for a while, it should probably be mentioned in the docs that this is only available at the top level and not when you're nested in a collection. Just sayin' ;)

 

Unfortunately, switching the GraphQL has gained me A LOT in some areas and lost in others.

 

0 Likes