Merge pull request #393 from automatisch/issue-389
feat: add paging capability in getFlows query
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
import Context from '../../types/express/context';
|
||||
import paginate from '../../helpers/pagination';
|
||||
import Flow from '../../models/flow';
|
||||
|
||||
type Params = {
|
||||
appKey?: string;
|
||||
limit: number;
|
||||
offset: number;
|
||||
};
|
||||
|
||||
const getFlows = async (_parent: unknown, params: Params, context: Context) => {
|
||||
const flowsQuery = context.currentUser
|
||||
.$relatedQuery('flows')
|
||||
.withGraphJoined('[steps.[connection]]')
|
||||
.orderBy('created_at', 'desc');
|
||||
const flowsQuery = Flow.query()
|
||||
.joinRelated('steps')
|
||||
.withGraphFetched('steps.[connection]')
|
||||
.where('flows.user_id', context.currentUser.id)
|
||||
.andWhere((builder) => {
|
||||
if (params.appKey) {
|
||||
builder.where('steps.app_key', params.appKey);
|
||||
}
|
||||
})
|
||||
.orderBy('updated_at', 'desc');
|
||||
|
||||
if (params.appKey) {
|
||||
flowsQuery.where('steps.app_key', params.appKey);
|
||||
}
|
||||
|
||||
const flows = await flowsQuery;
|
||||
|
||||
return flows;
|
||||
return paginate(flowsQuery, params.limit, params.offset);
|
||||
};
|
||||
|
||||
export default getFlows;
|
||||
|
@@ -4,7 +4,7 @@ type Query {
|
||||
getConnectedApps(name: String): [App]
|
||||
testConnection(id: String!): Connection
|
||||
getFlow(id: String!): Flow
|
||||
getFlows(appKey: String): [Flow]
|
||||
getFlows(limit: Int!, offset: Int!, appKey: String): FlowConnection
|
||||
getStepWithTestExecutions(stepId: String!): [Step]
|
||||
getExecutions(limit: Int!, offset: Int!): ExecutionConnection
|
||||
getExecutionSteps(
|
||||
@@ -189,6 +189,15 @@ type Field {
|
||||
clickToCopy: Boolean
|
||||
}
|
||||
|
||||
type FlowConnection {
|
||||
edges: [FlowEdge]
|
||||
pageInfo: PageInfo
|
||||
}
|
||||
|
||||
type FlowEdge {
|
||||
node: Flow
|
||||
}
|
||||
|
||||
type Flow {
|
||||
id: String
|
||||
name: String
|
||||
|
Reference in New Issue
Block a user