Skip to content

Commit

Permalink
fix(createResolversModel.ts): fix dynamic field loading logic to hand…
Browse files Browse the repository at this point in the history
…le both object and non-object related fields properly
  • Loading branch information
jhon-alex-gil-franco committed Sep 12, 2024
1 parent a06829f commit eaea2c2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/createResolversModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down

0 comments on commit eaea2c2

Please sign in to comment.