feat: Convert all mutation files to js

This commit is contained in:
Faruk AYDIN
2023-12-28 13:53:16 +01:00
parent 47dd5a1949
commit 8d6f0f8e9e
42 changed files with 229 additions and 706 deletions

View File

@@ -0,0 +1,35 @@
const deleteStep = async (_parent, params, context) => {
context.currentUser.can('update', 'Flow');
const step = await context.currentUser
.$relatedQuery('steps')
.withGraphFetched('flow')
.findOne({
'steps.id': params.input.id,
})
.throwIfNotFound();
await step.$relatedQuery('executionSteps').delete();
await step.$query().delete();
const nextSteps = await step.flow
.$relatedQuery('steps')
.where('position', '>', step.position);
const nextStepQueries = nextSteps.map(async (nextStep) => {
await nextStep.$query().patch({
position: nextStep.position - 1,
});
});
await Promise.all(nextStepQueries);
step.flow = await step.flow
.$query()
.withGraphJoined('steps')
.orderBy('steps.position', 'asc');
return step;
};
export default deleteStep;