refactor: rewrite get execution using useExecution with RQ

This commit is contained in:
Rıdvan Akca
2024-03-11 14:40:11 +03:00
parent 8d9c43af6a
commit 46491269e3
8 changed files with 28 additions and 52 deletions

View File

@@ -1,25 +0,0 @@
import Execution from '../../models/execution.js';
const getExecution = async (_parent, params, context) => {
const conditions = context.currentUser.can('read', 'Execution');
const userExecutions = context.currentUser.$relatedQuery('executions');
const allExecutions = Execution.query();
const executionBaseQuery = conditions.isCreator
? userExecutions
: allExecutions;
const execution = await executionBaseQuery
.clone()
.withGraphFetched({
flow: {
steps: true,
},
})
.withSoftDeleted()
.findById(params.executionId)
.throwIfNotFound();
return execution;
};
export default getExecution;

View File

@@ -7,7 +7,6 @@ import getConnectedApps from './queries/get-connected-apps.js';
import getCurrentUser from './queries/get-current-user.js';
import getDynamicData from './queries/get-dynamic-data.js';
import getDynamicFields from './queries/get-dynamic-fields.js';
import getExecution from './queries/get-execution.js';
import getExecutions from './queries/get-executions.js';
import getFlow from './queries/get-flow.js';
import getFlows from './queries/get-flows.js';
@@ -39,7 +38,6 @@ const queryResolvers = {
getCurrentUser,
getDynamicData,
getDynamicFields,
getExecution,
getExecutions,
getFlow,
getFlows,

View File

@@ -13,7 +13,6 @@ type Query {
name: String
): FlowConnection
getStepWithTestExecutions(stepId: String!): [Step]
getExecution(executionId: String!): Execution
getExecutions(
limit: Int!
offset: Int!