chore: remove redundant update step mutation
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
import updateStep from './mutations/update-step.js';
|
|
||||||
|
|
||||||
// Converted mutations
|
// Converted mutations
|
||||||
import executeFlow from './mutations/execute-flow.js';
|
import executeFlow from './mutations/execute-flow.js';
|
||||||
import updateUser from './mutations/update-user.ee.js';
|
import updateUser from './mutations/update-user.ee.js';
|
||||||
@@ -21,7 +19,6 @@ const mutationResolvers = {
|
|||||||
updateConnection,
|
updateConnection,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
updateFlowStatus,
|
updateFlowStatus,
|
||||||
updateStep,
|
|
||||||
updateUser,
|
updateUser,
|
||||||
verifyConnection,
|
verifyConnection,
|
||||||
};
|
};
|
||||||
|
@@ -1,68 +0,0 @@
|
|||||||
import App from '../../models/app.js';
|
|
||||||
import Step from '../../models/step.js';
|
|
||||||
import Connection from '../../models/connection.js';
|
|
||||||
|
|
||||||
const updateStep = async (_parent, params, context) => {
|
|
||||||
const { isCreator } = context.currentUser.can('update', 'Flow');
|
|
||||||
const userSteps = context.currentUser.$relatedQuery('steps');
|
|
||||||
const allSteps = Step.query();
|
|
||||||
const baseQuery = isCreator ? userSteps : allSteps;
|
|
||||||
|
|
||||||
const { input } = params;
|
|
||||||
|
|
||||||
let step = await baseQuery
|
|
||||||
.findOne({
|
|
||||||
'steps.id': input.id,
|
|
||||||
flow_id: input.flow.id,
|
|
||||||
})
|
|
||||||
.throwIfNotFound();
|
|
||||||
|
|
||||||
if (input.connection.id) {
|
|
||||||
let canSeeAllConnections = false;
|
|
||||||
try {
|
|
||||||
const conditions = context.currentUser.can('read', 'Connection');
|
|
||||||
|
|
||||||
canSeeAllConnections = !conditions.isCreator;
|
|
||||||
} catch {
|
|
||||||
// void
|
|
||||||
}
|
|
||||||
|
|
||||||
const userConnections = context.currentUser.$relatedQuery('connections');
|
|
||||||
const allConnections = Connection.query();
|
|
||||||
const baseConnectionsQuery = canSeeAllConnections
|
|
||||||
? allConnections
|
|
||||||
: userConnections;
|
|
||||||
|
|
||||||
const connection = await baseConnectionsQuery
|
|
||||||
.clone()
|
|
||||||
.findById(input.connection?.id);
|
|
||||||
|
|
||||||
if (!connection) {
|
|
||||||
throw new Error('The connection does not exist!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step.isTrigger) {
|
|
||||||
await App.checkAppAndTrigger(input.appKey, input.key);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step.isAction) {
|
|
||||||
await App.checkAppAndAction(input.appKey, input.key);
|
|
||||||
}
|
|
||||||
|
|
||||||
step = await Step.query()
|
|
||||||
.patchAndFetchById(input.id, {
|
|
||||||
key: input.key,
|
|
||||||
appKey: input.appKey,
|
|
||||||
connectionId: input.connection.id,
|
|
||||||
parameters: input.parameters,
|
|
||||||
status: 'incomplete'
|
|
||||||
})
|
|
||||||
.withGraphFetched('connection');
|
|
||||||
|
|
||||||
await step.updateWebhookUrl();
|
|
||||||
|
|
||||||
return step;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default updateStep;
|
|
@@ -10,7 +10,6 @@ type Mutation {
|
|||||||
updateConnection(input: UpdateConnectionInput): Connection
|
updateConnection(input: UpdateConnectionInput): Connection
|
||||||
updateCurrentUser(input: UpdateCurrentUserInput): User
|
updateCurrentUser(input: UpdateCurrentUserInput): User
|
||||||
updateFlowStatus(input: UpdateFlowStatusInput): Flow
|
updateFlowStatus(input: UpdateFlowStatusInput): Flow
|
||||||
updateStep(input: UpdateStepInput): Step
|
|
||||||
updateUser(input: UpdateUserInput): User
|
updateUser(input: UpdateUserInput): User
|
||||||
verifyConnection(input: VerifyConnectionInput): Connection
|
verifyConnection(input: VerifyConnectionInput): Connection
|
||||||
}
|
}
|
||||||
@@ -245,17 +244,6 @@ input ExecuteFlowInput {
|
|||||||
stepId: String!
|
stepId: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
input UpdateStepInput {
|
|
||||||
id: String
|
|
||||||
previousStepId: String
|
|
||||||
key: String
|
|
||||||
appKey: String
|
|
||||||
connection: StepConnectionInput
|
|
||||||
flow: StepFlowInput
|
|
||||||
parameters: JSONObject
|
|
||||||
previousStep: PreviousStepInput
|
|
||||||
}
|
|
||||||
|
|
||||||
input CreateUserInput {
|
input CreateUserInput {
|
||||||
fullName: String!
|
fullName: String!
|
||||||
email: String!
|
email: String!
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
import { gql } from '@apollo/client';
|
|
||||||
export const UPDATE_STEP = gql`
|
|
||||||
mutation UpdateStep($input: UpdateStepInput) {
|
|
||||||
updateStep(input: $input) {
|
|
||||||
id
|
|
||||||
type
|
|
||||||
key
|
|
||||||
appKey
|
|
||||||
parameters
|
|
||||||
status
|
|
||||||
webhookUrl
|
|
||||||
connection {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
Reference in New Issue
Block a user