Can't filter products using query by collection

The Shopify documentation for the Products API endpoint does not provide an option to filter products directly by collection. While you can use collectionByHandle to retrieve products from a specific collection, there is no built-in way to fetch products that belong to multiple collections in a single query.

query getProducts($first: Int) {
  products(first: $first) {
    edges {
      cursor
      node {
        title
      }
    }
  }
}

You can make multiple calls in one query with GraphQL, so you could simply do the following (note you’ll need to remove any duplicates).

query {
  collectionByHandle(handle: "new-arrivals") {
    products {
      ...
    }
  }
  collectionByHandle(handle: "best-sellers") {
    products {
      ...
    }
  }
}