fix(update-flow-status): throw at incomplete trigger step
This commit is contained in:
@@ -30,6 +30,11 @@ const updateFlowStatus = async (_parent, params, context) => {
|
||||
}
|
||||
|
||||
const triggerStep = await flow.getTriggerStep();
|
||||
|
||||
if (triggerStep.status === 'incomplete') {
|
||||
throw flow.IncompleteStepsError;
|
||||
}
|
||||
|
||||
const trigger = await triggerStep.getTriggerCommand();
|
||||
const interval = trigger.getInterval?.(triggerStep.parameters);
|
||||
const repeatOptions = {
|
||||
|
@@ -112,6 +112,13 @@ class Flow extends Base {
|
||||
return lastExecutions.map((execution) => execution.internalId);
|
||||
}
|
||||
|
||||
get IncompleteStepsError() {
|
||||
return new ValidationError({
|
||||
message: 'All steps should be completed before updating flow status!',
|
||||
type: 'incompleteStepsError',
|
||||
});
|
||||
}
|
||||
|
||||
async $beforeUpdate(opt, queryContext) {
|
||||
await super.$beforeUpdate(opt, queryContext);
|
||||
|
||||
@@ -124,10 +131,7 @@ class Flow extends Base {
|
||||
});
|
||||
|
||||
if (incompleteStep) {
|
||||
throw new ValidationError({
|
||||
message: 'All steps should be completed before updating flow status!',
|
||||
type: 'incompleteStepsError',
|
||||
});
|
||||
throw this.IncompleteStepsError;
|
||||
}
|
||||
|
||||
const allSteps = await oldFlow.$relatedQuery('steps');
|
||||
|
Reference in New Issue
Block a user