Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 11x 11x 11x 11x 11x 11x 11x 11x 11x 22x 11x 11x 22x 11x 22x 11x 22x 11x | import { Resolver, Query, Mutation, Args } from '@nestjs/graphql';
import { UsersService } from '@app/modules/users/users.service';
import { User } from '@app/modules/users/user.model';
import { UseGuards } from '@nestjs/common';
import { GqlAuthGuard } from '@app/common/guards/gql-auth.guard';
import { RolesGuard } from '@app/common/guards/roles.guard';
import { Roles } from '@app/common/decorators/roles.decorator';
import { CurrentUser } from '@app/common/decorators/current-user.decorator';
import { UpdateUserInput } from '@app/modules/users/dto/update-user.input';
@Resolver(() => User)
export class UsersResolver {
constructor(private readonly usersService: UsersService) {}
/** GraphQL query `users` */
@Query(() => [User], { description: 'Return all users' })
@UseGuards(GqlAuthGuard, RolesGuard)
@Roles('ADMIN')
users() {
return this.usersService.findAll();
}
@Query(() => User, { name: 'me', nullable: true })
@UseGuards(GqlAuthGuard)
me(@CurrentUser() user: any) {
return this.usersService.findOneById(user.id);
}
@Mutation(() => User)
@UseGuards(GqlAuthGuard)
updateProfile(
@CurrentUser() user: any,
@Args('updateUserInput') updateUserInput: UpdateUserInput,
) {
return this.usersService.update(user.id, updateUserInput);
}
} |