Skip to content

Commit

Permalink
fix: errorCatcher does not require mongodb package anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
nodkz committed Jun 1, 2021
1 parent 3adf5f5 commit be509fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/errors/MongoError.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { MongoError } from 'mongodb';
import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose';

export { MongoError };

export function getMongoErrorOTC(schemaComposer: SchemaComposer<any>): ObjectTypeComposer {
return schemaComposer.getOrCreateOTC('MongoError', (otc) => {
otc.addFields({
Expand Down
4 changes: 2 additions & 2 deletions src/resolvers/helpers/errorCatcher.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down Expand Up @@ -33,7 +33,7 @@ export function addErrorCatcherField(resolver: Resolver<any, any, any>): void {
message: e.message,
errors: e.errors,
};
} else if (e instanceof MongoError) {
} else if (e?.constructor.name === 'MongoError') {
error = {
name: 'MongoError',
message: e.message,
Expand Down

0 comments on commit be509fa

Please sign in to comment.