mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 02:01:40 -05:00
apollo-server-core: added formatApolloError arguments to subscription callback
This commit is contained in:
parent
a7772a01fb
commit
e0332bb164
1 changed files with 13 additions and 4 deletions
|
@ -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<Request = RequestInit> {
|
|||
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<Request = RequestInit> {
|
|||
? 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 };
|
||||
|
|
Loading…
Add table
Reference in a new issue