Access denied error with "published_status:published" in collectionByHandle GraphQL API method.

New Member
4 0 0

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.

0 Likes
Shopify Staff
Shopify Staff
799 33 102

Hey there, 

 

Thanks for pointing this out - something definitely seems incorrect there. I'll raise this with our development team and let you know once I hear back from them! 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
799 33 102

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

 

0 Likes