feat: Return only related flows with given app

This commit is contained in:
Faruk AYDIN
2022-05-08 00:35:48 +02:00
committed by Ali BARIN
parent 9f56fd7c3b
commit 7c543ff8ed
2 changed files with 13 additions and 7 deletions

View File

@@ -1,15 +1,21 @@
import Context from '../../types/express/context'; import Context from '../../types/express/context';
const getFlows = async ( type Params = {
_parent: unknown, appKey?: string;
_params: unknown, };
context: Context
) => { const getFlows = async (_parent: unknown, params: Params, context: Context) => {
const flows = await context.currentUser const flowsQuery = context.currentUser
.$relatedQuery('flows') .$relatedQuery('flows')
.withGraphJoined('[steps.[connection]]') .withGraphJoined('[steps.[connection]]')
.orderBy('created_at', 'desc'); .orderBy('created_at', 'desc');
if (params.appKey) {
flowsQuery.where('steps.app_key', params.appKey);
}
const flows = await flowsQuery;
return flows; return flows;
}; };

View File

@@ -5,7 +5,7 @@ type Query {
getAppConnections(key: AvailableAppsEnumType!): [Connection] getAppConnections(key: AvailableAppsEnumType!): [Connection]
testConnection(id: String!): Connection testConnection(id: String!): Connection
getFlow(id: String!): Flow getFlow(id: String!): Flow
getFlows: [Flow] getFlows(appKey: String): [Flow]
getStepWithTestExecutions(stepId: String!): [Step] getStepWithTestExecutions(stepId: String!): [Step]
getExecutions(limit: Int!, offset: Int!): ExecutionConnection getExecutions(limit: Int!, offset: Int!): ExecutionConnection
getExecutionSteps( getExecutionSteps(