diff --git a/packages/apollo-server-core/src/ApolloServer.ts b/packages/apollo-server-core/src/ApolloServer.ts index af2c7eb8..db2d850b 100644 --- a/packages/apollo-server-core/src/ApolloServer.ts +++ b/packages/apollo-server-core/src/ApolloServer.ts @@ -19,7 +19,7 @@ import { import { formatApolloErrors } from './errors'; import { GraphQLServerOptions as GraphQLOptions } from './graphqlOptions'; -import { LogFunction } from './logging'; +import { LogFunction, LogAction, LogStep } from './logging'; import { Config, @@ -212,7 +212,13 @@ export class ApolloServerBase { onOperation: async (_: string, connection: ExecutionParams) => { connection.formatResponse = (value: ExecutionResult) => ({ ...value, - errors: value.errors && formatApolloErrors(value.errors), + errors: + value.errors && + formatApolloErrors(value.errors, { + formatter: this.requestOptions.formatError, + debug: this.requestOptions.debug, + logFunction: this.requestOptions.logFunction, + }), }); let context: Context = this.context ? this.context : { connection }; @@ -222,8 +228,11 @@ export class ApolloServerBase { ? await this.context({ connection }) : context; } catch (e) { - console.error(e); - throw e; + throw formatApolloErrors([e], { + formatter: this.requestOptions.formatError, + debug: this.requestOptions.debug, + logFunction: this.requestOptions.logFunction, + })[0]; } return { ...connection, context };