Initial commit: Prism messenger with Expo + NestJS + GraphQL + PostgreSQL
This commit is contained in:
34
backend/src/modules/auth/auth.resolver.ts
Normal file
34
backend/src/modules/auth/auth.resolver.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Resolver, Mutation, Args, ObjectType, Field } from '@nestjs/graphql';
|
||||
import { AuthService } from './auth.service';
|
||||
import { User } from '../users/entities/user.entity';
|
||||
|
||||
@ObjectType()
|
||||
class AuthResponse {
|
||||
@Field()
|
||||
access_token: string;
|
||||
|
||||
@Field(() => User)
|
||||
user: User;
|
||||
}
|
||||
|
||||
@Resolver()
|
||||
export class AuthResolver {
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
@Mutation(() => AuthResponse)
|
||||
async login(
|
||||
@Args('username') username: string,
|
||||
@Args('password') password: string,
|
||||
) {
|
||||
return this.authService.login(username, password);
|
||||
}
|
||||
|
||||
@Mutation(() => AuthResponse)
|
||||
async register(
|
||||
@Args('username') username: string,
|
||||
@Args('email') email: string,
|
||||
@Args('password') password: string,
|
||||
) {
|
||||
return this.authService.register(username, email, password);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user