From 04f8a712440c479e5f8fee9c0928129b64fc65ec Mon Sep 17 00:00:00 2001 From: Ali BARIN Date: Wed, 10 Aug 2022 21:21:27 +0200 Subject: [PATCH] feat: add connectionId filter in getFlows query --- packages/backend/src/graphql/queries/get-flows.ts | 15 +++++++++++++-- packages/backend/src/graphql/schema.graphql | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/graphql/queries/get-flows.ts b/packages/backend/src/graphql/queries/get-flows.ts index 1b72af81..4f89364e 100644 --- a/packages/backend/src/graphql/queries/get-flows.ts +++ b/packages/backend/src/graphql/queries/get-flows.ts @@ -3,6 +3,7 @@ import paginate from '../../helpers/pagination'; type Params = { appKey?: string; + connectionId?: string; name?: string; limit: number; offset: number; @@ -11,9 +12,19 @@ type Params = { const getFlows = async (_parent: unknown, params: Params, context: Context) => { const flowsQuery = context.currentUser .$relatedQuery('flows') - .joinRelated('steps') - .withGraphFetched('steps.[connection]') + .joinRelated({ + steps: true + }) + .withGraphFetched({ + steps: { + connection: true + } + }) .where((builder) => { + if (params.connectionId) { + builder.where('steps.connection_id', params.connectionId); + } + if (params.name) { builder.where('flows.name', 'ilike', `%${params.name}%`); } diff --git a/packages/backend/src/graphql/schema.graphql b/packages/backend/src/graphql/schema.graphql index e841a2de..54b60b87 100644 --- a/packages/backend/src/graphql/schema.graphql +++ b/packages/backend/src/graphql/schema.graphql @@ -8,6 +8,7 @@ type Query { limit: Int! offset: Int! appKey: String + connectionId: String name: String ): FlowConnection getStepWithTestExecutions(stepId: String!): [Step]