So I have a relational mongo database that looks something like this
Location {
_id: ...
shopIDs: <List of Shop IDs in another collection>
}
Shops {
_id: ...
...
}
Also I already have my GraphQL Setup in place and the Schema. But to get a Query like
locations {
shops {
name
}
}
I need to create another Resolver that connects the shopIDs field to the shop collection, right?
So I did something like:
Location: {
shopIDs: async ({ shopIDs }, args, context) => {
return await Shop.find({ _id: { $in: shopIDs } });
}
},
But the shopIDs is undefined and when I console logged the parent object it was only the ID of the parent. Now my question: Do I really have to look up the parent with mongoose again to get the ShopIDs? I have not find any related Question, so I hope this have not yet been answered. Thank you!