refactor: Use graphql schema directly with graphql-tools library

This commit is contained in:
Faruk AYDIN
2022-03-06 18:16:28 +03:00
committed by Ömer Faruk Aydın
parent 96cca96bff
commit 9926e5589e
48 changed files with 551 additions and 839 deletions

View File

@@ -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;