feat: Add deleteStep mutation

This commit is contained in:
Faruk AYDIN
2022-01-28 20:38:54 +03:00
committed by Ali BARIN
parent da9ab8016b
commit 5b392f3f87
2 changed files with 37 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
import { GraphQLInt, GraphQLNonNull, GraphQLBoolean } from 'graphql';
import Step from '../../models/step';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
type Params = {
id: number;
};
const deleteStepResolver = async (
params: Params,
req: RequestWithCurrentUser
) => {
// TODO: This logic should be revised by using current user
await Step.query()
.delete()
.findOne({
id: params.id,
})
.throwIfNotFound();
return;
};
const deleteStep = {
type: GraphQLBoolean,
args: {
id: { type: GraphQLNonNull(GraphQLInt) },
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
deleteStepResolver(params, req),
};
export default deleteStep;