chore: remove redundant delete step mutation

This commit is contained in:
Ali BARIN
2024-09-18 15:50:01 +00:00
committed by Faruk AYDIN
parent f94a5385d7
commit 1297f5d43c
4 changed files with 0 additions and 61 deletions

View File

@@ -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,

View File

@@ -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;

View File

@@ -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!

View File

@@ -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
}
}
}
}
`;