Graph QL - Access denied Issue

Highlighted
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?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 183

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. 

 

 

0 Likes
Highlighted
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,

0 Likes
Highlighted
Shopify Staff
Shopify Staff
1129 82 183

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. 

 

0 Likes