fix: remove circular serialization in GQL errors

This commit is contained in:
Ali BARIN
2022-11-30 16:57:35 +01:00
parent 945b777c3c
commit 2f06cda82b

View File

@@ -1,12 +1,13 @@
import { graphqlHTTP } from 'express-graphql';
import logger from '../helpers/logger';
import { applyMiddleware } from 'graphql-middleware';
import authentication from '../helpers/authentication';
import { join } from 'path';
import { graphqlHTTP } from 'express-graphql';
import { loadSchemaSync } from '@graphql-tools/load';
import { GraphQLFileLoader } from '@graphql-tools/graphql-file-loader';
import { addResolversToSchema } from '@graphql-tools/schema';
import { applyMiddleware } from 'graphql-middleware';
import logger from '../helpers/logger';
import authentication from '../helpers/authentication';
import resolvers from '../graphql/resolvers';
import HttpError from '../errors/http';
const schema = loadSchemaSync(join(__dirname, '../graphql/schema.graphql'), {
loaders: [new GraphQLFileLoader()],
@@ -23,6 +24,10 @@ const graphQLInstance = graphqlHTTP({
customFormatErrorFn: (error) => {
logger.error(error.path + ' : ' + error.message + '\n' + error.stack);
if (error.originalError instanceof HttpError) {
delete (error.originalError as HttpError).response;
}
return error.originalError;
},
});