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,18 +1,15 @@
import { GraphQLNonNull } from 'graphql';
import App from '../../models/app';
import appType from '../types/app';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
import availableAppsEnumType from '../types/available-apps-enum-type';
import Context from '../../types/express/context';
type Params = {
key: string;
};
const getAppResolver = async (params: Params, req: RequestWithCurrentUser) => {
const getApp = async (_parent: unknown, params: Params, context: Context) => {
const app = App.findOneByKey(params.key);
if (req.currentUser) {
const connections = await req.currentUser
if (context.currentUser) {
const connections = await context.currentUser
.$relatedQuery('connections')
.where({
key: params.key,
@@ -27,13 +24,4 @@ const getAppResolver = async (params: Params, req: RequestWithCurrentUser) => {
return app;
};
const getApp = {
type: appType,
args: {
key: { type: GraphQLNonNull(availableAppsEnumType) },
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
getAppResolver(params, req),
};
export default getApp;