Files
automatisch/packages/backend/src/graphql/mutations/execute-flow.ts
2022-10-14 22:33:26 +02:00

34 lines
696 B
TypeScript

import Context from '../../types/express/context';
import testRun from '../../services/test-run';
type Params = {
input: {
stepId: string;
};
};
const executeFlow = async (
_parent: unknown,
params: Params,
context: Context
) => {
const { stepId } = params.input;
const { executionStep } = await testRun({ stepId });
const untilStep = await context.currentUser
.$relatedQuery('steps')
.findById(stepId);
await untilStep.$query().patch({
status: 'completed',
});
if (executionStep.isFailed) {
throw new Error(JSON.stringify(executionStep.errorDetails));
}
return { data: executionStep.dataOut, step: untilStep };
};
export default executeFlow;