feat: Implement updateFlowStatus mutation

This commit is contained in:
Faruk AYDIN
2022-03-07 20:35:05 +03:00
committed by Ömer Faruk Aydın
parent 63198a6569
commit 64011b5c4b
4 changed files with 36 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import verifyConnection from './mutations/verify-connection';
import deleteConnection from './mutations/delete-connection';
import createFlow from './mutations/create-flow';
import updateFlow from './mutations/update-flow';
import updateFlowStatus from './mutations/update-flow-status';
import executeFlow from './mutations/execute-flow';
import deleteFlow from './mutations/delete-flow';
import createStep from './mutations/create-step';
@@ -22,6 +23,7 @@ const mutationResolvers = {
deleteConnection,
createFlow,
updateFlow,
updateFlowStatus,
executeFlow,
deleteFlow,
createStep,

View File

@@ -0,0 +1,31 @@
import Context from '../../types/express/context';
type Params = {
id: string;
active: boolean;
};
const updateFlowStatus = async (
_parent: unknown,
params: Params,
context: Context
) => {
let flow = await context.currentUser
.$relatedQuery('flows')
.findOne({
id: params.id,
})
.throwIfNotFound();
if (flow.active === params.active) {
return flow;
}
flow = await flow.$query().patchAndFetch({
active: params.active,
});
return flow;
};
export default updateFlowStatus;

View File

@@ -3,7 +3,6 @@ import Context from '../../types/express/context';
type Params = {
id: string;
name: string;
active: boolean;
};
const updateFlow = async (
@@ -20,7 +19,6 @@ const updateFlow = async (
flow = await flow.$query().patchAndFetch({
name: params.name,
active: params.active,
});
return flow;

View File

@@ -20,12 +20,13 @@ type Mutation {
verifyConnection(id: String!): Connection
deleteConnection(id: String!): Boolean
createFlow(input: FlowInput): Flow
updateFlow(id: String!, name: String!, active: Boolean): Flow
updateFlow(id: String!, name: String!): Flow
updateFlowStatus(id: String!, active: Boolean!): Flow
executeFlow(stepId: String!): executeFlowType
deleteFlow(id: String!): Boolean
createStep(input: StepInput!): Step
updateStep(input: StepInput!): Step
deleteStep(id: String!): Step
executeFlow(stepId: String!): executeFlowType
login(email: String!, password: String!): Auth
}