mirror of
https://github.com/vale981/apollo-server
synced 2025-03-06 10:11: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 { formatApolloErrors } from './errors';
|
||||||
import { GraphQLServerOptions as GraphQLOptions } from './graphqlOptions';
|
import { GraphQLServerOptions as GraphQLOptions } from './graphqlOptions';
|
||||||
import { LogFunction } from './logging';
|
import { LogFunction, LogAction, LogStep } from './logging';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Config,
|
Config,
|
||||||
|
@ -212,7 +212,13 @@ export class ApolloServerBase<Request = RequestInit> {
|
||||||
onOperation: async (_: string, connection: ExecutionParams) => {
|
onOperation: async (_: string, connection: ExecutionParams) => {
|
||||||
connection.formatResponse = (value: ExecutionResult) => ({
|
connection.formatResponse = (value: ExecutionResult) => ({
|
||||||
...value,
|
...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 };
|
let context: Context = this.context ? this.context : { connection };
|
||||||
|
|
||||||
|
@ -222,8 +228,11 @@ export class ApolloServerBase<Request = RequestInit> {
|
||||||
? await this.context({ connection })
|
? await this.context({ connection })
|
||||||
: context;
|
: context;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
throw formatApolloErrors([e], {
|
||||||
throw e;
|
formatter: this.requestOptions.formatError,
|
||||||
|
debug: this.requestOptions.debug,
|
||||||
|
logFunction: this.requestOptions.logFunction,
|
||||||
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return { ...connection, context };
|
return { ...connection, context };
|
||||||
|
|
Loading…
Add table
Reference in a new issue