Skip to content

Commit

Permalink
fix(server): use subscription specific formatter for queries and muta…
Browse files Browse the repository at this point in the history
…tions too
  • Loading branch information
enisdenjo committed Aug 27, 2020
1 parent 0303c09 commit 5672a04
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,14 @@ export function createServer(
}
} else {
let result = subscriptionOrResult;
// use the root formater first
if (formatExecutionResult) {
result = await formatExecutionResult(ctx, result);
}
// use the subscription specific formatter
if (executionResultFormatter) {
result = await executionResultFormatter(ctx, result);
}
await sendMessage<MessageType.Next>(ctx, {
id: message.id,
type: MessageType.Next,
Expand All @@ -448,9 +453,14 @@ export function createServer(
// operationAST.operation === 'query' || 'mutation'

let result = await execute(execArgs);
// use the root formater first
if (formatExecutionResult) {
result = await formatExecutionResult(ctx, result);
}
// use the subscription specific formatter
if (executionResultFormatter) {
result = await executionResultFormatter(ctx, result);
}
await sendMessage<MessageType.Next>(ctx, {
id: message.id,
type: MessageType.Next,
Expand Down

0 comments on commit 5672a04

Please sign in to comment.