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';
const getFlows = async (
_parent: unknown,
_params: unknown,
context: Context
) => {
const flows = await context.currentUser
type Params = {
appKey?: string;
};
const getFlows = async (_parent: unknown, params: Params, context: Context) => {
const flowsQuery = context.currentUser
.$relatedQuery('flows')
.withGraphJoined('[steps.[connection]]')
.orderBy('created_at', 'desc');
if (params.appKey) {
flowsQuery.where('steps.app_key', params.appKey);
}
const flows = await flowsQuery;
return flows;
};

View File

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