I'm trying to get published products list using GraphQL admin API. This query works fine:
query getProducts { products(first: 10, query: "published_status:published") { pageInfo { hasNextPage hasPreviousPage } edges { cursor node { publishedOnCurrentPublication storefrontId id title handle } } } }
But I need to get products from some collection. Fox example collection with handle "somehandle". Here is my query:
query getProductsByCollectionHandle { collectionByHandle(handle: "somehandle") { id title handle products(first: 10, query: "published_status:published") { pageInfo { hasNextPage hasPreviousPage } edges { cursor node { publishedOnCurrentPublication storefrontId id title handle } } } } }
I'm getting error "access denied":
{"data":{"collectionByHandle":null},"errors":[{"message":"access denied","locations":[{"line":7,"column":5}],"path":["collectionByHandle","products"]}],"extensions":{"cost":{"requestedQueryCost":13,"actualQueryCost":1,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":997,"restoreRate":50.0}}}}
If I remove query: "published_status:published" then this query works without errors. I think this is a bug in collectionByHandle GraphQL admin API. Because the same query works in products method.
Hey again,
So this is expected right now - it is a very expensive query that we don't want to allow. We're going to look at other ways this can be accomplished.
In the meantime, you may want to consider using REST :
/admin/products.json?collection_id=#{collection_id}&published_status=published
Subject | Author | Posted |
---|---|---|
22m ago | ||
an hour ago | ||
2 hours ago | ||
yesterday | ||
yesterday |
User | Count |
---|---|
257 | |
165 | |
134 | |
67 | |
39 |