Skip to content

Commit

Permalink
Merge pull request #63 from zhumeisongsong/feature/new-UserDto-in-Res…
Browse files Browse the repository at this point in the history
…olver

fix: 🐛 new UserDto when getUser in Resolver
  • Loading branch information
zhumeisongsong authored Nov 20, 2024
2 parents 13a0728 + fbb2630 commit 220cf0b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libs/users/interface-adapters/src/lib/resolver/users.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ export class UsersResolver {
constructor(private usersService: UsersService) {}

@Query(() => UserDto, { nullable: true })
getUser(@Args({ name: 'id', type: () => ID }) id: string): Promise<UserDto | null> {
return this.usersService.findById(id);
async getUser(@Args({ name: 'id', type: () => ID }) id: string): Promise<UserDto | null> {
const user = await this.usersService.findById(id);

if (!user) {
return null;
}

return new UserDto(user.id, user.name);
}
}

0 comments on commit 220cf0b

Please sign in to comment.