chore: remove redundant delete step mutation
This commit is contained in:
@@ -3,7 +3,6 @@ import updateStep from './mutations/update-step.js';
|
||||
// Converted mutations
|
||||
import executeFlow from './mutations/execute-flow.js';
|
||||
import updateUser from './mutations/update-user.ee.js';
|
||||
import deleteStep from './mutations/delete-step.js';
|
||||
import verifyConnection from './mutations/verify-connection.js';
|
||||
import updateCurrentUser from './mutations/update-current-user.js';
|
||||
import generateAuthUrl from './mutations/generate-auth-url.js';
|
||||
@@ -16,7 +15,6 @@ import updateFlowStatus from './mutations/update-flow-status.js';
|
||||
const mutationResolvers = {
|
||||
createConnection,
|
||||
createUser,
|
||||
deleteStep,
|
||||
executeFlow,
|
||||
generateAuthUrl,
|
||||
resetConnection,
|
||||
|
@@ -1,40 +0,0 @@
|
||||
import Step from '../../models/step.js';
|
||||
|
||||
const deleteStep = 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 step = await baseQuery
|
||||
.withGraphFetched('flow')
|
||||
.findOne({
|
||||
'steps.id': params.input.id,
|
||||
})
|
||||
.throwIfNotFound();
|
||||
|
||||
await step.$relatedQuery('executionSteps').delete();
|
||||
await step.$query().delete();
|
||||
|
||||
const nextSteps = await step.flow
|
||||
.$relatedQuery('steps')
|
||||
.where('position', '>', step.position);
|
||||
|
||||
const nextStepQueries = nextSteps.map(async (nextStep) => {
|
||||
await nextStep.$query().patch({
|
||||
position: nextStep.position - 1,
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(nextStepQueries);
|
||||
|
||||
step.flow = await step.flow
|
||||
.$query()
|
||||
.withGraphJoined('steps')
|
||||
.orderBy('steps.position', 'asc');
|
||||
|
||||
return step;
|
||||
};
|
||||
|
||||
export default deleteStep;
|
@@ -4,7 +4,6 @@ type Query {
|
||||
type Mutation {
|
||||
createConnection(input: CreateConnectionInput): Connection
|
||||
createUser(input: CreateUserInput): UserWithAcceptInvitationUrl
|
||||
deleteStep(input: DeleteStepInput): Step
|
||||
executeFlow(input: ExecuteFlowInput): executeFlowType
|
||||
generateAuthUrl(input: GenerateAuthUrlInput): AuthLink
|
||||
resetConnection(input: ResetConnectionInput): Connection
|
||||
@@ -257,10 +256,6 @@ input UpdateStepInput {
|
||||
previousStep: PreviousStepInput
|
||||
}
|
||||
|
||||
input DeleteStepInput {
|
||||
id: String!
|
||||
}
|
||||
|
||||
input CreateUserInput {
|
||||
fullName: String!
|
||||
email: String!
|
||||
|
@@ -1,14 +0,0 @@
|
||||
import { gql } from '@apollo/client';
|
||||
export const DELETE_STEP = gql`
|
||||
mutation DeleteStep($input: DeleteStepInput) {
|
||||
deleteStep(input: $input) {
|
||||
id
|
||||
flow {
|
||||
id
|
||||
steps {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
Reference in New Issue
Block a user