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