Initial commit: Prism messenger with Expo + NestJS + GraphQL + PostgreSQL

This commit is contained in:
Bivekich
2025-08-06 02:19:37 +03:00
commit 6fb83334d6
56 changed files with 24295 additions and 0 deletions

View File

@ -0,0 +1,39 @@
import { Resolver, Query, Mutation, Args, ID } from '@nestjs/graphql';
import { UsersService } from './users.service';
import { User } from './entities/user.entity';
import { UseGuards } from '@nestjs/common';
import { GqlAuthGuard } from '../auth/guards/gql-auth.guard';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
@Resolver(() => User)
export class UsersResolver {
constructor(private readonly usersService: UsersService) {}
@Query(() => [User], { name: 'users' })
@UseGuards(GqlAuthGuard)
findAll() {
return this.usersService.findAll();
}
@Query(() => User, { name: 'user' })
@UseGuards(GqlAuthGuard)
findOne(@Args('id', { type: () => ID }) id: string) {
return this.usersService.findOne(id);
}
@Query(() => User, { name: 'me' })
@UseGuards(GqlAuthGuard)
getMe(@CurrentUser() user: User) {
return this.usersService.findOne(user.id);
}
@Mutation(() => User)
@UseGuards(GqlAuthGuard)
updateUser(
@CurrentUser() user: User,
@Args('bio', { nullable: true }) bio?: string,
@Args('avatar', { nullable: true }) avatar?: string,
) {
return this.usersService.update(user.id, { bio, avatar });
}
}