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,13 +1,11 @@
import { GraphQLNonNull, GraphQLString } from 'graphql';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
import flowType from '../types/flow';
import Context from '../../types/express/context';
type Params = {
id: string;
};
const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
const flow = await req.currentUser
const getFlow = async (_parent: unknown, params: Params, context: Context) => {
const flow = await context.currentUser
.$relatedQuery('flows')
.withGraphJoined('[steps.[connection]]')
.orderBy('steps.position', 'asc')
@@ -17,13 +15,4 @@ const getFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
return flow;
};
const getFlow = {
type: flowType,
args: {
id: { type: GraphQLNonNull(GraphQLString) },
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
getFlowResolver(params, req),
};
export default getFlow;