Created
March 4, 2018 07:56
-
-
Save akoenig/0dd16f6b49dc1b1eb2099b63c626e342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// path: resolvers/mutation/login/index.ts | |
import { WrongCredentialsError } from "./errors/WrongCredentialsError"; | |
interface LoginInput { | |
username: string; | |
password: string; | |
} | |
const login = await (parent, args: LoginInput, context: Context, info) { | |
const user = await context.db.query.user({where: {username: args.username}}); | |
const areCredentialsValid = checkCredentials(user, args.password); | |
if (!areCredentialsValid) { | |
throw new WrongCredentialsError(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment