Skip to content

Commit

Permalink
fix: Format errors sent over websocket
Browse files Browse the repository at this point in the history
Format errors sent over websocket
  • Loading branch information
schickling authored Mar 11, 2018
2 parents f985fd5 + 08fd47c commit 6e998a5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ export class GraphQLServer {
: async (connectionParams, webSocket) => ({ ...connectionParams }),
onDisconnect: subscriptionServerOptions.onDisconnect,
onOperation: async (message, connection, webSocket) => {
// The following should be replaced when SubscriptionServer accepts a formatError
// parameter for custom error formatting.
// See https://github.com/apollographql/subscriptions-transport-ws/issues/182
connection.formatResponse = value => ({
...value,
errors: value.errors && value.errors.map(this.options.formatError || defaultErrorFormatter),
})

let context
try {
context =
Expand Down

0 comments on commit 6e998a5

Please sign in to comment.