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,28 @@
import testRun from '../../services/test-run';
import Step from '../../models/step';
const executeFlow = async (_parent, params, context) => {
const conditions = context.currentUser.can('update', 'Flow');
const isCreator = conditions.isCreator;
const allSteps = Step.query();
const userSteps = context.currentUser.$relatedQuery('steps');
const baseQuery = isCreator ? userSteps : allSteps;
const { stepId } = params.input;
const untilStep = await baseQuery.clone().findById(stepId).throwIfNotFound();
const { executionStep } = await testRun({ stepId });
if (executionStep.isFailed) {
throw new Error(JSON.stringify(executionStep.errorDetails));
}
await untilStep.$query().patch({
status: 'completed',
});
return { data: executionStep.dataOut, step: untilStep };
};
export default executeFlow;