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,7 +1,5 @@
|
||||
import { GraphQLNonNull } from 'graphql';
|
||||
import Step from '../../models/step';
|
||||
import stepType, { stepInputType } from '../types/step';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import Context from '../../types/express/context';
|
||||
|
||||
type Params = {
|
||||
input: {
|
||||
@@ -17,13 +15,15 @@ type Params = {
|
||||
};
|
||||
};
|
||||
};
|
||||
const updateStepResolver = async (
|
||||
|
||||
const updateStep = async (
|
||||
_parent: unknown,
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
context: Context
|
||||
) => {
|
||||
const { input } = params;
|
||||
|
||||
let step = await req.currentUser
|
||||
let step = await context.currentUser
|
||||
.$relatedQuery('steps')
|
||||
.findOne({
|
||||
'steps.id': input.id,
|
||||
@@ -43,13 +43,4 @@ const updateStepResolver = async (
|
||||
return step;
|
||||
};
|
||||
|
||||
const updateStep = {
|
||||
type: stepType,
|
||||
args: {
|
||||
input: { type: new GraphQLNonNull(stepInputType) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
updateStepResolver(params, req),
|
||||
};
|
||||
|
||||
export default updateStep;
|
||||
|
Reference in New Issue
Block a user