feat: Implement onlyWithTriggers flag for getApps graphQL query
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
7740529a2a
commit
6c0ba197c6
@@ -1,21 +1,29 @@
|
||||
import { GraphQLString, GraphQLList } from 'graphql';
|
||||
import { GraphQLString, GraphQLList, GraphQLBoolean } from 'graphql';
|
||||
import appType from '../types/app';
|
||||
import App from '../../models/app';
|
||||
|
||||
type Params = {
|
||||
name: string
|
||||
}
|
||||
name: string;
|
||||
onlyWithTriggers: boolean;
|
||||
};
|
||||
|
||||
const getAppsResolver = (params: Params) => {
|
||||
return App.findAll(params.name)
|
||||
}
|
||||
const apps = App.findAll(params.name);
|
||||
|
||||
if (params.onlyWithTriggers) {
|
||||
return apps.filter((app: any) => app.triggers?.length);
|
||||
}
|
||||
|
||||
return apps;
|
||||
};
|
||||
|
||||
const getApps = {
|
||||
type: GraphQLList(appType),
|
||||
args: {
|
||||
name: { type: GraphQLString }
|
||||
name: { type: GraphQLString },
|
||||
onlyWithTriggers: { type: GraphQLBoolean },
|
||||
},
|
||||
resolve: (_: any, params: Params) => getAppsResolver(params)
|
||||
}
|
||||
resolve: (_: any, params: Params) => getAppsResolver(params),
|
||||
};
|
||||
|
||||
export default getApps;
|
||||
|
Reference in New Issue
Block a user