diff --git a/src/errors/MongoError.ts b/src/errors/MongoError.ts index dc46d1e2..4939b007 100644 --- a/src/errors/MongoError.ts +++ b/src/errors/MongoError.ts @@ -1,8 +1,5 @@ -import { MongoError } from 'mongodb'; import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose'; -export { MongoError }; - export function getMongoErrorOTC(schemaComposer: SchemaComposer): ObjectTypeComposer { return schemaComposer.getOrCreateOTC('MongoError', (otc) => { otc.addFields({ diff --git a/src/resolvers/helpers/errorCatcher.ts b/src/resolvers/helpers/errorCatcher.ts index 4a0b48e2..1a4b931a 100644 --- a/src/resolvers/helpers/errorCatcher.ts +++ b/src/resolvers/helpers/errorCatcher.ts @@ -1,5 +1,5 @@ import { Resolver } from 'graphql-compose'; -import { getErrorInterface, MongoError, ValidationError } from '../../errors'; +import { getErrorInterface, ValidationError } from '../../errors'; import { GraphQLError } from 'graphql-compose/lib/graphql'; /** @@ -33,7 +33,7 @@ export function addErrorCatcherField(resolver: Resolver): void { message: e.message, errors: e.errors, }; - } else if (e instanceof MongoError) { + } else if (e?.constructor.name === 'MongoError') { error = { name: 'MongoError', message: e.message,