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, GraphQLBoolean } from 'graphql';
|
||||
import flowType from '../types/flow';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import Context from '../../types/express/context';
|
||||
|
||||
type Params = {
|
||||
id: string;
|
||||
@@ -8,11 +6,12 @@ type Params = {
|
||||
active: boolean;
|
||||
};
|
||||
|
||||
const updateFlowResolver = async (
|
||||
const updateFlow = async (
|
||||
_parent: unknown,
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
context: Context
|
||||
) => {
|
||||
let flow = await req.currentUser
|
||||
let flow = await context.currentUser
|
||||
.$relatedQuery('flows')
|
||||
.findOne({
|
||||
id: params.id,
|
||||
@@ -24,15 +23,4 @@ const updateFlowResolver = async (
|
||||
return flow;
|
||||
};
|
||||
|
||||
const updateFlow = {
|
||||
type: flowType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
name: { type: GraphQLNonNull(GraphQLString) },
|
||||
active: { type: GraphQLBoolean },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
updateFlowResolver(params, req),
|
||||
};
|
||||
|
||||
export default updateFlow;
|
||||
|
Reference in New Issue
Block a user