refactor: Use graphql schema directly with graphql-tools library

This commit is contained in:
Faruk AYDIN
2022-03-06 18:16:28 +03:00
committed by Ömer Faruk Aydın
parent 96cca96bff
commit 9926e5589e
48 changed files with 551 additions and 839 deletions

View File

@@ -1,29 +1,19 @@
import { GraphQLString, GraphQLList, GraphQLBoolean } from 'graphql';
import appType from '../types/app';
import App from '../../models/app';
import { IApp } from '@automatisch/types';
type Params = {
name: string;
onlyWithTriggers: boolean;
};
const getAppsResolver = (params: Params) => {
const getApps = (_parent: unknown, params: Params) => {
const apps = App.findAll(params.name);
if (params.onlyWithTriggers) {
return apps.filter((app: any) => app.triggers?.length);
return apps.filter((app: IApp) => app.triggers?.length);
}
return apps;
};
const getApps = {
type: GraphQLList(appType),
args: {
name: { type: GraphQLString },
onlyWithTriggers: { type: GraphQLBoolean },
},
resolve: (_: any, params: Params) => getAppsResolver(params),
};
export default getApps;