feat: Add deleteStep mutation
This commit is contained in:
33
packages/backend/src/graphql/mutations/delete-step.ts
Normal file
33
packages/backend/src/graphql/mutations/delete-step.ts
Normal 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;
|
Reference in New Issue
Block a user