Skip to content

Instantly share code, notes, and snippets.

@akoenig
Created March 4, 2018 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akoenig/0dd16f6b49dc1b1eb2099b63c626e342 to your computer and use it in GitHub Desktop.
Save akoenig/0dd16f6b49dc1b1eb2099b63c626e342 to your computer and use it in GitHub Desktop.
// 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