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,4 +1,4 @@
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLEnumType } from 'graphql';
|
||||
import { GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import App from '../../models/app';
|
||||
import connectionType from '../types/connection';
|
||||
@@ -28,7 +28,7 @@ const createConnectionResolver = async (params: Params, req: RequestWithCurrentU
|
||||
const createConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
key: { type: availableAppsEnumType },
|
||||
key: { type: GraphQLNonNull(availableAppsEnumType) },
|
||||
data: { type: GraphQLNonNull(GraphQLJSONObject) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => createConnectionResolver(params, req)
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { GraphQLList, GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import { GraphQLList, GraphQLNonNull } from 'graphql';
|
||||
import Connection from '../../models/connection';
|
||||
import App from '../../models/app';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import connectionType from '../types/connection';
|
||||
import availableAppsEnumType from '../types/available-apps-enum-type';
|
||||
|
||||
type Params = {
|
||||
key: string
|
||||
@@ -22,7 +23,7 @@ const getAppConnectionsResolver = async (params: Params, req: RequestWithCurrent
|
||||
const getAppConnections = {
|
||||
type: GraphQLList(connectionType),
|
||||
args: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) }
|
||||
key: { type: GraphQLNonNull(availableAppsEnumType) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => getAppConnectionsResolver(params, req)
|
||||
}
|
||||
|
@@ -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