Open pixel-mattp opened 3 years ago
You have to add a releation to your ObjectTypeComposer object, like this
TC.getFieldOTC("colours").addRelation("colour", { resolver: () => ColorTC.mongooseResolvers.findByIds(), prepareArgs: { _ids: (source) => source.colours.map((o) => o._id) || null, }, projection: { colour: true }, });
I have a Schema as follows:
I am trying to use the
addRelation
function to populate the colour object inside each array item, however because it's within a nested array (not an object) I'm struggling to make it work.Am I missing something?
Thanks!