Hello,
I am trying to query another api from my module which is related by the user module via the email key for each user. Each user can have possibly one api entry belonging to him but it can also be null.
User Module:
user.entity
...
@Field(() => ApiUser, { nullable: true })
api?: ApiUser;
...
user.resolver
@ResolveField(() => ApiUser, { nullable: true })
async api(
@Parent() user: User,
@Loader(ApiUserLoader)
apiUserLoader: DataLoader<ApiUser["email"], ApiUser>,
): Promise<ApiUser> {
const email = user.email;
return apiUserLoader.load(email);
}
API Module:
api-user.loader.ts
protected getOptions = () => ({
propertyKey: "email",
query: async (keys: Array<ApiUser["email"]>) => {
const users = await this.apiUserService.findByEmails(keys);
return users;
},
});
The API ignores user it does not find. E.g. returns [] for a single entry if it can't find it.
If I query for a user which the external API does not know I get this error by the data loader:
{
"message": "ApiUser does not exist (example@googlemail.com)",
}
Since the field api in the resolver is nullable I would expect that I get null returned.
Thank you.
Hello,
I am trying to query another api from my module which is related by the user module via the
emailkey for each user. Each user can have possibly one api entry belonging to him but it can also benull.User Module:
user.entity
user.resolver
API Module:
api-user.loader.ts
The API ignores user it does not find. E.g. returns
[]for a single entry if it can't find it.If I query for a user which the external API does not know I get this error by the data loader:
{ "message": "ApiUser does not exist (example@googlemail.com)", }Since the field
apiin the resolver is nullable I would expect that I getnullreturned.Thank you.