Update to Apollo Server 2

This commit is contained in:
Barry Low committed 2018-10-17 20:59:45 -07:00
1 parent 6a4c557c57
commit fe5b291985
9 files changed
+2071 -285

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { ApolloError } from 'apollo-server-express'
import { logger } from '../logger'
export {
ApolloError,
AuthenticationError,
ForbiddenError,
SyntaxError,
UserInputError,
ValidationError,
} from 'apollo-server-express'
export function formatError(error) {
// This can be used to send errors to third
// party services like Sentry or Stackdriver
logger.error(error)
return error
}
// Define custom Apollo errors here
export class ExternalServiceError extends ApolloError {
constructor(message) {
super(message, 'EXTERNAL_SERVICE_UNAVAILABLE')
Object.defineProperty(this, 'name', { value: this.constructor.name })
}
}