Query Products By Multiple Collection

Highlighted
New Member
1 0 0

Using graphQL, is it possible to query products by the multiple collections in one Call? 

I know how to do this for one collection:

query {  collectionByHandle(handle: "collection-handle") {    products(first: 250) {      edges {        node {          id
          title
          description
          tags
        }
      }
    }
  }
}

But can we do this search on multiple collections in one GraphQL call? Please assist. Thanks

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 103 124

Hey @Rook ,

 

You can query multiple collections with one call based on their collection title, by utilizing the "query" parameter of the Collections Query Root:

 

{
  collections(first:10, query:"title:'title1' OR title:'title2' OR title:'title3'") {
    edges {
      node {
       title
       id
    }
    }
  }
}

However you might face some difficulties if you use this method to query for products under collections. As of right now there are limitations to how products can be queried under a collection. This is dependent on the collection being either a custom collection or a smart collection, and also based on the technology used for performing these searches. This is a good thread to read on the subject: https://community.shopify.com/c/Shopify-APIs-SDKs/Getting-quot-access-denied-quot-when-querying-with...

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes