I created a NestJS sample, I add a Mutation
to sync user info to my backend.
And added the following codes, the @GqlUser is to extract user info from my jwt token.
@Mutation((returns) => UpdateUserResult)
@UseGuards(JwtAuthGuard)
updateUser(@GqlUser() user: UserPrincipal): Observable<UpdateUserResult> {
console.log('gql user:', user);
const { userId, email, name } = user;
return this.usersService.update({ id: userId, email, name }).pipe(
map((b) => ({
success: b,
})),
);
}
But when executing this mutation by the following forms.
// failed due to *the expectedName is not a ")"*
mutation SyncUser{
updateUser(){
success
}
}
or
// failed due to *this.subQuery is not a function*
mutation {
updateUser{
success
}
}
It always tried to retrieve the input arguments, failed.