feat: Implement getStepWithTestExecutions query
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { GraphQLNonNull, GraphQLString, GraphQLList } from 'graphql';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import stepType from '../types/step';
|
||||
|
||||
type Params = {
|
||||
stepId: string;
|
||||
};
|
||||
|
||||
const getStepWithTestExecutionsResolver = async (
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
) => {
|
||||
const step = await req.currentUser
|
||||
.$relatedQuery('steps')
|
||||
.findOne({ 'steps.id': params.stepId })
|
||||
.throwIfNotFound();
|
||||
|
||||
const previousStepsWithCurrentStep = await req.currentUser
|
||||
.$relatedQuery('steps')
|
||||
.withGraphJoined('executionSteps')
|
||||
.select('steps.*', 'executionSteps.data_out as output')
|
||||
.where('flow_id', '=', step.flowId)
|
||||
.andWhere('position', '<=', step.position)
|
||||
.distinctOn('executionSteps.step_id')
|
||||
.orderBy([
|
||||
'executionSteps.step_id',
|
||||
{ column: 'executionSteps.created_at', order: 'desc' },
|
||||
]);
|
||||
|
||||
return previousStepsWithCurrentStep;
|
||||
};
|
||||
|
||||
const getStepWithTestExecutions = {
|
||||
type: GraphQLList(stepType),
|
||||
args: {
|
||||
stepId: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
getStepWithTestExecutionsResolver(params, req),
|
||||
};
|
||||
|
||||
export default getStepWithTestExecutions;
|
@@ -6,6 +6,7 @@ import getAppConnections from './queries/get-app-connections';
|
||||
import testConnection from './queries/test-connection';
|
||||
import getFlow from './queries/get-flow';
|
||||
import getFlows from './queries/get-flows';
|
||||
import getStepWithTestExecutions from './queries/get-step-with-test-executions';
|
||||
|
||||
const rootQuery = new GraphQLObjectType({
|
||||
name: 'Query',
|
||||
@@ -17,6 +18,7 @@ const rootQuery = new GraphQLObjectType({
|
||||
testConnection,
|
||||
getFlow,
|
||||
getFlows,
|
||||
getStepWithTestExecutions,
|
||||
},
|
||||
});
|
||||
|
||||
|
15
packages/backend/src/graphql/types/execution-step.ts
Normal file
15
packages/backend/src/graphql/types/execution-step.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLBoolean } from 'graphql';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
|
||||
const executionStepType = new GraphQLObjectType({
|
||||
name: 'ExecutionStep',
|
||||
fields: {
|
||||
executionId: { type: GraphQLString },
|
||||
stepId: { type: GraphQLString },
|
||||
status: { type: GraphQLString },
|
||||
dataIn: { type: GraphQLJSONObject },
|
||||
dataOut: { type: GraphQLJSONObject },
|
||||
},
|
||||
});
|
||||
|
||||
export default executionStepType;
|
@@ -5,6 +5,7 @@ import {
|
||||
GraphQLInt,
|
||||
GraphQLInputObjectType,
|
||||
} from 'graphql';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
import ConnectionType from './connection';
|
||||
|
||||
const stepType = new GraphQLObjectType({
|
||||
@@ -27,9 +28,10 @@ const stepType = new GraphQLObjectType({
|
||||
},
|
||||
}),
|
||||
},
|
||||
parameters: { type: GraphQLString },
|
||||
parameters: { type: GraphQLJSONObject },
|
||||
connection: { type: ConnectionType },
|
||||
flow: { type: FlowType },
|
||||
output: { type: GraphQLJSONObject },
|
||||
position: { type: GraphQLInt },
|
||||
status: { type: GraphQLString },
|
||||
};
|
||||
|
Reference in New Issue
Block a user