refactor: Use graphql schema directly with graphql-tools library
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
96cca96bff
commit
9926e5589e
@@ -1,6 +1,4 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import User from '../../models/user';
|
||||
import authType from '../types/auth';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import appConfig from '../../config/app';
|
||||
|
||||
@@ -9,7 +7,7 @@ type Params = {
|
||||
password: string;
|
||||
};
|
||||
|
||||
const loginResolver = async (params: Params) => {
|
||||
const login = async (_parent: unknown, params: Params) => {
|
||||
const user = await User.query().findOne({
|
||||
email: params.email,
|
||||
});
|
||||
@@ -23,13 +21,4 @@ const loginResolver = async (params: Params) => {
|
||||
throw new Error('User could not be found.');
|
||||
};
|
||||
|
||||
const login = {
|
||||
type: authType,
|
||||
args: {
|
||||
email: { type: GraphQLNonNull(GraphQLString) },
|
||||
password: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: any) => loginResolver(params),
|
||||
};
|
||||
|
||||
export default login;
|
||||
|
Reference in New Issue
Block a user