I'm using Wordpress, Woocommerce, WooGraphQL, React and Next for a headless eCommerce solution, utilizing SSG and SSR for SEO and performance.
I'm concerned about performance when it comes to populating product filters on category pages. I only want to show filters relating to the products that match the search.
Hypothetical example:
- Product search yields 500 results.
- Request data for the first 12 products using GraphQL to show on the first page.
- (Issue) Getting the data to populate the filters for all 500 products.
In my case, the filters are product categories, and each product is linked to 3 categories.
The only thing I can think of is to request data for all 500 products and then loop over each product in the array in order to access the related categories and populate the filters.
In my real-world project, there will really be no more than maybe 100 products but I'd ideally like to take a scalable approach.
Is pulling this amount of data something I should be concerned about or am I overthinking it? (I'm guessing not) If not, what would be a better solution to this kind of problem?
Example GraphQL request would look like this:
query MyQuery {
products(first: 500, where: {search: "something"}) {
nodes {
productCategories {
nodes {
name
}
}
}
}
}
I understand that taking a page by page appoach to pulling data is best. But the problem of gathering up so much data still stands.