diff --git a/src/utils/createResolversModel.ts b/src/utils/createResolversModel.ts index 9ac834e..76f12b0 100644 --- a/src/utils/createResolversModel.ts +++ b/src/utils/createResolversModel.ts @@ -81,7 +81,7 @@ const createResolvers = async (model: GQLModel, parsedModels: GQLModel[]) => { return `${rf.name}: async (parent: ${model.name}, _: null, { db, session }) => { ${unCapitalize(model.name)}DataLoader.${rf.name}Loader.clearAll() - return await ${unCapitalize(model.name)}DataLoader.${rf.name}Loader.load(parent.${relatedField}); + return await ${unCapitalize(model.name)}DataLoader.${rf.name}Loader.load(parent.${typeof relatedField=== 'object'?'id':relatedField}); }`; } else { return `${rf.name}: async (parent: ${model.name}, _: null, { db,session }) => {