diff --git a/libs/users/presentation/resolver/src/lib/users.resolver.ts b/libs/users/presentation/resolver/src/lib/users.resolver.ts index 88ac9fa..1b5a730 100644 --- a/libs/users/presentation/resolver/src/lib/users.resolver.ts +++ b/libs/users/presentation/resolver/src/lib/users.resolver.ts @@ -1,14 +1,16 @@ import { Args, ID, Query, Resolver, ResolveReference } from '@nestjs/graphql'; import { UsersService } from '@users/application'; import { User } from '@user/domain'; +import { UserDto } from '@users/presentation-dto'; -@Resolver(() => User) +@Resolver(() => UserDto) export class UsersResolver { constructor(private usersService: UsersService) {} - @Query(() => User, { nullable: true }) - getUser(@Args({ name: 'id', type: () => ID }) id: string): User | undefined { - return this.usersService.findById(id); + @Query(() => UserDto, { nullable: true }) + getUser(@Args({ name: 'id', type: () => ID }) id: string): UserDto | null { + const user: User | undefined = this.usersService.findById(id); // Domain entity + return user ? new UserDto(user.id, user.name) : null; } @ResolveReference()