Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/subscription-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,11 @@ module.exports = class SubscriptionConnection {

sendError (err, id) {
const convertedError = toGraphQLError(err)
// Graphql over websocket spec requires that errors are wrapped in an array
this.sendMessage(this.protocolMessageTypes.GQL_ERROR, id, [convertedError])
// graphql-transport-ws requires errors wrapped in an array; the legacy
// subscriptions-transport-ws protocol (identified as 'graphql-ws') expects
// a single error object instead.
const payload = this.socket.protocol === 'graphql-ws' ? convertedError : [convertedError]
this.sendMessage(this.protocolMessageTypes.GQL_ERROR, id, payload)
}

async handleConnectionInitExtension (extension) {
Expand Down
Loading