0:00 So now we're ready to implement our authentication inside 0:04 of our auth resolver. Let's go ahead and 0:08 open up the auth resolver. So now that we have the JWT module, 0:11 we're ready to 0:12 implement a mutation that a user can call to supply their 0:15 credentials, 0:16 and if valid, well, we're gonna assign and return them a JWT. 0:21 So in this auth resolver, let's go ahead and create this mutation 0:25 with the @mutation decorator, 0:28 and we'll go ahead, and for this auth resolver, 0:31 we have to return 0:32 a type from each 0:34 GraphQL operation. So we'll return the user 0:38 associated with this token as part of this mutation. 0:45 And then we'll go ahead and define the async login method. 0:50 So this login method is now going to take in some input, 0:53 and that's gonna be 0:54 the user's credentials, their email and password that they're trying to 0:57 authenticate with. So let's go ahead and define this inside of 1:00 the auth folder. Just like we would for any other service, 1:04 we'll create a new 1:04 DTO folder. 1:07 This is data transfer object, and just like we did for create user 1:10 input, 1:11 I wanna create a new 1:13 login.input in this directory. 1:18 Let's go ahead and create this with @input type, 1:21 and we'll go ahead and import this from nest-graphql 1:25 and export the login input class. 1:28 So like I said, this is gonna take in two parameters, 1:31 the email and 1:32 string that we are trying to authenticate with, and that's going 1:36 to be the email and password. 1:38 So just like we do in any GraphQL input type, we need to decorate this with 1:42 the @field decorator. And then to ensure that these 1:45 properties are actually valid, we can use, again, class 1:49 validator. I'll use the is not empty 1:52 decorator. 1:54 And we'll go ahead and do the same thing for the password,
The rest of the transcript is for members.
Sign in