Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Graph QL - Access denied Issue

Graph QL - Access denied Issue

Shailesh-Px
Shopify Partner
3 0 0

API Type: Graph QL

 

Purpose: Filter products by product's collection id

 

Query: { collection(id: "gid://shopify/Collection/94480302191"){ products(query:"title:'Tip' OR sku:'Tip'",first:15){ edges{ node{ id, title, images(first:1) { edges { node { id, originalSrc altText } } }, variants(first:50){ edges{ node{ id, title price inventoryQuantity } } } metafield(namespace:"Candela",key:"LotSize"){ value } } cursor } } } }

 

Problem/Issue: When we run graphql query, We are getting "access denied" error. https://prnt.sc/p83khh 

 

Can anyone help me?

Replies 3 (3)

Josh
Shopify Staff
1134 84 235

Hey @Shailesh-Px ,

 

When querying products within a collection, you're not able to use the query argument to filter products further. This is intentional, because the queries can be extremely expensive.

 

You'll find if you remove the query argument from products so it's just (first:15) this will succeed. 

 

 

Josh | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Shailesh-Px
Shopify Partner
3 0 0

Hello Josh

 

Thank you for your response.

 

I want to filter products with a collection id. Let me know if any other solution using graphQL query. I found query in your document but the query is not working.

 

{
  products(first:5, query:"collection_type:t-shirt"){
    edges{
      node{
        id
      }
    }
  }
}

Can you help me?

 

Thanks,

Josh
Shopify Staff
1134 84 235

Hello again @Shailesh-Px ,

 

When looking at our documentation for QueryRoot.products, I'm only seeing the following fields documented for use under query (collection_type isn't there) : 

 

  • barcode
  • created_at
  • delivery_profile_id
  • error_feedback
  • gift_card
  • inventory_total
  • out_of_stock_somewhere
  • product_type
  • published_status
  • sku
  • tag
  • title
  • updated_at
  • vendor

Or is your post only a portion of your GraphQL query? Query should not be documented as part of collection.products, I've logged an issue to remove that as it doesn't work and isn't meant to be documented there. It will only work when looking up products directly, not within a collection. 

 

Josh | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog