chore: Use available apps enum type in queries and mutations
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
63d478f9a9
commit
9ea5242d94
@@ -1,19 +1,15 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLNonNull } from 'graphql';
|
||||
import App from '../../models/app';
|
||||
import appType from '../types/app';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import Connection from '../../models/connection';
|
||||
import connectionType from '../types/connection';
|
||||
import availableAppsEnumType from '../types/available-apps-enum-type';
|
||||
|
||||
type Params = {
|
||||
key: string
|
||||
}
|
||||
|
||||
const getAppResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
if(!params.key) {
|
||||
throw new Error('No key provided.')
|
||||
}
|
||||
|
||||
const app = App.findOneByKey(params.key);
|
||||
|
||||
if (req.currentUser?.id) {
|
||||
@@ -32,7 +28,7 @@ const getAppResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const getApp = {
|
||||
type: appType,
|
||||
args: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
key: { type: GraphQLNonNull(availableAppsEnumType) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getAppResolver(params, req)
|
||||
}
|
||||
|
Reference in New Issue
Block a user