Hi!
I'm looking for the best way to get all products that are within several collections, using Storefront API (Graphql).
I'm currently using the following query, but then I need to filter out all products from their collection in a separate array (Which is fine I guess). It has to be possible in some other way right?
query ($ids:[ID!]!) {
nodes(ids: $ids) {
... on Collection {
id
products(first: 250) {
I recommend using Apollo Boost so that you can connect to your store like so:
import fetch from 'node-fetch'
import ApolloClient, { gql } from 'apollo-boost'
const client = new ApolloClient({
uri: 'https://your-store-name.myshopify.com/api/2020-10/graphql.json',
headers: {
'X-Shopify-Storefront-Access-Token': 'abc123'
},
fetch: fetch,
});
client.query({
query: gql`
{
collections(first: 10) {
edges {
node {
id
title
products(first: 100) {
edges {
node {
id
title
description
variants(first: 10) {
edges {
node {
id
title
price
image {
src
}
}
}
}
}
}
}
}
}
}
}
`
User | Count |
---|---|
2 | |
2 | |
2 | |
1 | |
1 |