From e7822f7a5148c5539374dc767af024274c2cd267 Mon Sep 17 00:00:00 2001 From: Dan Ribbens Date: Fri, 20 Nov 2020 15:36:04 -0500 Subject: [PATCH] refactor ts graphql index --- src/collections/graphql/init.ts | 2 +- src/express/middleware/errorHandler.ts | 4 +++- src/graphql/index.ts | 11 ++--------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/collections/graphql/init.ts b/src/collections/graphql/init.ts index 0f79a7e6bf..fadc2e1a85 100644 --- a/src/collections/graphql/init.ts +++ b/src/collections/graphql/init.ts @@ -296,4 +296,4 @@ function registerCollections() { }); } -module.exports = registerCollections; +export default registerCollections; diff --git a/src/express/middleware/errorHandler.ts b/src/express/middleware/errorHandler.ts index df4fa1c26b..cd24a37ed1 100644 --- a/src/express/middleware/errorHandler.ts +++ b/src/express/middleware/errorHandler.ts @@ -1,6 +1,8 @@ import httpStatus from 'http-status'; import formatErrorResponse from '../responses/formatError'; -const logger = require('../../utilities/logger')(); +import utilities from '../../utilities/logger'; + +const logger = utilities(); const errorHandler = (config) => async (err, req, res, next) => { const data = formatErrorResponse(err); diff --git a/src/graphql/index.ts b/src/graphql/index.ts index f3b62f0344..60d62d349d 100644 --- a/src/graphql/index.ts +++ b/src/graphql/index.ts @@ -1,6 +1,6 @@ -import GraphQL from 'graphql'; -import queryComplexityImport from 'graphql-query-complexity'; +import GraphQL, { GraphQLObjectType, GraphQLSchema } from 'graphql'; import graphQLHTTP from 'express-graphql'; +import queryComplexity, { simpleEstimator, fieldExtensionsEstimator } from 'graphql-query-complexity'; import buildObjectType from './schema/buildObjectType'; import buildMutationInputType from './schema/buildMutationInputType'; import errorHandler from './errorHandler'; @@ -13,13 +13,6 @@ import initGlobals from '../globals/graphql/init'; import buildWhereInputType from './schema/buildWhereInputType'; import access from '../auth/graphql/resolvers/access'; -const { GraphQLObjectType, GraphQLSchema } = GraphQL; -const queryComplexity = queryComplexityImport.default; -const { - fieldExtensionsEstimator, - simpleEstimator, -} = queryComplexityImport; - class InitializeGraphQL { constructor(init) { Object.assign(this, init);