chore: remove redundant create step mutation
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import createConnection from './mutations/create-connection.js';
|
import createConnection from './mutations/create-connection.js';
|
||||||
import createStep from './mutations/create-step.js';
|
|
||||||
import createUser from './mutations/create-user.ee.js';
|
import createUser from './mutations/create-user.ee.js';
|
||||||
import deleteFlow from './mutations/delete-flow.js';
|
import deleteFlow from './mutations/delete-flow.js';
|
||||||
import deleteRole from './mutations/delete-role.ee.js';
|
import deleteRole from './mutations/delete-role.ee.js';
|
||||||
@@ -23,7 +22,6 @@ import deleteCurrentUser from './mutations/delete-current-user.ee.js';
|
|||||||
const mutationResolvers = {
|
const mutationResolvers = {
|
||||||
createConnection,
|
createConnection,
|
||||||
createFlow,
|
createFlow,
|
||||||
createStep,
|
|
||||||
createUser,
|
createUser,
|
||||||
deleteCurrentUser,
|
deleteCurrentUser,
|
||||||
deleteFlow,
|
deleteFlow,
|
||||||
|
@@ -1,56 +0,0 @@
|
|||||||
import App from '../../models/app.js';
|
|
||||||
import Flow from '../../models/flow.js';
|
|
||||||
|
|
||||||
const createStep = async (_parent, params, context) => {
|
|
||||||
const conditions = context.currentUser.can('update', 'Flow');
|
|
||||||
const userFlows = context.currentUser.$relatedQuery('flows');
|
|
||||||
const allFlows = Flow.query();
|
|
||||||
const flowsQuery = conditions.isCreator ? userFlows : allFlows;
|
|
||||||
|
|
||||||
const { input } = params;
|
|
||||||
|
|
||||||
if (input.appKey && input.key) {
|
|
||||||
await App.checkAppAndAction(input.appKey, input.key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input.appKey && !input.key) {
|
|
||||||
await App.findOneByKey(input.appKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
const flow = await flowsQuery
|
|
||||||
.findOne({
|
|
||||||
id: input.flow.id,
|
|
||||||
})
|
|
||||||
.throwIfNotFound();
|
|
||||||
|
|
||||||
const previousStep = await flow
|
|
||||||
.$relatedQuery('steps')
|
|
||||||
.findOne({
|
|
||||||
id: input.previousStep.id,
|
|
||||||
})
|
|
||||||
.throwIfNotFound();
|
|
||||||
|
|
||||||
const step = await flow.$relatedQuery('steps').insertAndFetch({
|
|
||||||
key: input.key,
|
|
||||||
appKey: input.appKey,
|
|
||||||
type: 'action',
|
|
||||||
position: previousStep.position + 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
const nextSteps = await flow
|
|
||||||
.$relatedQuery('steps')
|
|
||||||
.where('position', '>=', step.position)
|
|
||||||
.whereNot('id', step.id);
|
|
||||||
|
|
||||||
const nextStepQueries = nextSteps.map(async (nextStep, index) => {
|
|
||||||
await nextStep.$query().patchAndFetch({
|
|
||||||
position: step.position + index + 1,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
await Promise.all(nextStepQueries);
|
|
||||||
|
|
||||||
return step;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default createStep;
|
|
@@ -4,7 +4,6 @@ type Query {
|
|||||||
type Mutation {
|
type Mutation {
|
||||||
createConnection(input: CreateConnectionInput): Connection
|
createConnection(input: CreateConnectionInput): Connection
|
||||||
createFlow(input: CreateFlowInput): Flow
|
createFlow(input: CreateFlowInput): Flow
|
||||||
createStep(input: CreateStepInput): Step
|
|
||||||
createUser(input: CreateUserInput): UserWithAcceptInvitationUrl
|
createUser(input: CreateUserInput): UserWithAcceptInvitationUrl
|
||||||
deleteCurrentUser: Boolean
|
deleteCurrentUser: Boolean
|
||||||
deleteFlow(input: DeleteFlowInput): Boolean
|
deleteFlow(input: DeleteFlowInput): Boolean
|
||||||
@@ -266,17 +265,6 @@ input DuplicateFlowInput {
|
|||||||
id: String!
|
id: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
input CreateStepInput {
|
|
||||||
id: String
|
|
||||||
previousStepId: String
|
|
||||||
key: String
|
|
||||||
appKey: String
|
|
||||||
connection: StepConnectionInput
|
|
||||||
flow: StepFlowInput
|
|
||||||
parameters: JSONObject
|
|
||||||
previousStep: PreviousStepInput
|
|
||||||
}
|
|
||||||
|
|
||||||
input UpdateStepInput {
|
input UpdateStepInput {
|
||||||
id: String
|
id: String
|
||||||
previousStepId: String
|
previousStepId: String
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
export const CREATE_STEP = gql`
|
|
||||||
mutation CreateStep($input: CreateStepInput) {
|
|
||||||
createStep(input: $input) {
|
|
||||||
id
|
|
||||||
type
|
|
||||||
key
|
|
||||||
appKey
|
|
||||||
parameters
|
|
||||||
iconUrl
|
|
||||||
position
|
|
||||||
webhookUrl
|
|
||||||
status
|
|
||||||
connection {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
Reference in New Issue
Block a user