Files
automatisch/packages/backend/src/graphql/queries/get-apps.ts
2022-10-15 13:35:14 +02:00

25 lines
522 B
TypeScript

import App from '../../models/app';
import { IApp } from '@automatisch/types';
type Params = {
name: string;
onlyWithTriggers: boolean;
onlyWithActions: boolean;
};
const getApps = async (_parent: unknown, params: Params) => {
const apps = await App.findAll(params.name);
if (params.onlyWithTriggers) {
return apps.filter((app: IApp) => app.triggers?.length);
}
if (params.onlyWithActions) {
return apps.filter((app: IApp) => app.actions?.length);
}
return apps;
};
export default getApps;