Closed runemadsen closed 6 years ago
For others with this problem, you have to filter the db results back to an array ordered by the original ids:
{
Product: {
images: createBatchResolver(async products => {
const pids = products.map(p => p.id);
const images = await db.find("images", { productId: pids });
return pids.map(id => images.filter(img => img.productId === id));
})
}
I'm not sure whether this package still works for
graphql-tools
. I have the following code:And this resolver:
I am getting the following error:
Error: Expected Iterable, but did not find one for field Product.images.
. However, myconsole.log
logs an array of images. Is this a problem with async/await?