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,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;
|
||||
|
Reference in New Issue
Block a user