Files
automatisch/packages/backend/src/graphql/queries/get-apps.ts
2023-07-18 21:06:22 +00:00

25 lines
522 B
TypeScript

import { IApp } from '@automatisch/types';
import App from '../../models/app';
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;