Get products from graphql endpoint, Collection - Product Hierarchy

Get products from graphql endpoint, Collection - Product Hierarchy

Deva
New Member
7 0 0

query product from collection

query myquery{

collectionByHandle(handle:"handle_name")

  {

      products(first: 10 query:"price:>10 price:<=8000")

      {

            edges

             {

                  node

                  {

                        id

                        title

                        variants(first:10)

                        {

                              edges

                              {

                                  node

                                  {

                                        id

                                        price

                                  }

                              }

                          }

                   }

              }

       }

   }

}

but I'm not able not to get products, i got response as 'access denied'

{
"data": {
"collectionByHandle": null
},
"errors": [
{
"message": "access denied",
"locations": [
{
"line": 7,
"column": 7
}
],
"path": [
"collectionByHandle",
"products"
]
}
],
"extensions": {
"cost": {
"requestedQueryCost": 133,
"actualQueryCost": 3,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 997,
"restoreRate": 50
}
}
}
}

Replies 3 (3)

hassain
Shopify Staff (Retired)
624 104 188

Hi @Deva ,

 

This is known behaviour. Shopify does not support the filtration/query of products within a Collection connection in the GraphQL Admin API, due to the expensive nature of queries. However if you removed the 'query' argument from the products and kept it as "first:10" only, you would not get any errors. Read the threads here for more information: 

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

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

To learn more visit the Shopify Help Center or the Community Blog.

Deva
New Member
7 0 0

Thank you @hassain for your reply ,

I'll need to filter products by particular range within  a collection, is there any room to retrieve it ?

gjgiraldo
Visitor
1 0 1

{
collectionByHandle(handle: "hip-hop-legends") {

products(first: 100) {
edges {
node {
id
title
}
}
}
}
}