refactor: Use graphql schema directly with graphql-tools library
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
96cca96bff
commit
9926e5589e
@@ -1,17 +1,16 @@
|
||||
import { GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import connectionType from '../types/connection';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
import Context from '../../types/express/context';
|
||||
import App from '../../models/app';
|
||||
|
||||
type Params = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
const verifyConnectionResolver = async (
|
||||
const verifyConnection = async (
|
||||
_parent: unknown,
|
||||
params: Params,
|
||||
req: RequestWithCurrentUser
|
||||
context: Context
|
||||
) => {
|
||||
let connection = await req.currentUser
|
||||
let connection = await context.currentUser
|
||||
.$relatedQuery('connections')
|
||||
.findOne({
|
||||
id: params.id,
|
||||
@@ -36,13 +35,4 @@ const verifyConnectionResolver = async (
|
||||
return connection;
|
||||
};
|
||||
|
||||
const verifyConnection = {
|
||||
type: connectionType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLString) },
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) =>
|
||||
verifyConnectionResolver(params, req),
|
||||
};
|
||||
|
||||
export default verifyConnection;
|
||||
|
Reference in New Issue
Block a user