feat: Implement getFlows graphQL query

This commit is contained in:
Faruk AYDIN
2021-12-09 17:42:22 +01:00
committed by Ömer Faruk Aydın
parent d8c216d8c8
commit 95d38b740e
2 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
import { GraphQLList, GraphQLString } from 'graphql';
import Flow from '../../models/flow';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
import flowType from '../types/flow';
const getFlowsResolver = async (req: RequestWithCurrentUser) => {
const flows = await Flow.query()
.where({ user_id: req.currentUser.id});
return flows;
}
const getFlows = {
type: GraphQLList(flowType),
resolve: (_: any, _params: any, req: RequestWithCurrentUser) => getFlowsResolver(req)
}
export default getFlows;

View File

@@ -4,6 +4,7 @@ import getApp from './queries/get-app';
import getConnectedApps from './queries/get-connected-apps';
import getAppConnections from './queries/get-app-connections';
import testConnection from './queries/test-connection';
import getFlows from './queries/get-flows';
const rootQuery = new GraphQLObjectType({
name: 'Query',
@@ -12,7 +13,8 @@ const rootQuery = new GraphQLObjectType({
getApp,
getConnectedApps,
getAppConnections,
testConnection
testConnection,
getFlows
}
});