Hey
Is it possible to fetch linked products with a certain brand with pagination as it is possible to do if I would be fetching only products or brands.
The solution I have now is not very optimized as it fetches all the products linked with a certain brand instead of just fetching what is needed and then im doing the pagination manually.
const brandId = req.validatedQuery.id || "";
const productLimit = req.validatedQuery.limit || 15;
const productOffset = req.validatedQuery.offset || 0;
//getting all the linked products
const { data: brands } = await query.graph({
entity: "brand",
fields: ["*", "products.*"],
filters: { id: brandId },
});
// paginate products
const brand = brands[0];
const products = brand?.products || [];
const paginatedProducts = products.slice(
productOffset,
productOffset + productLimit
);