diff --git a/src/server.ts b/src/server.ts index 0f4309eb..4396f70d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -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(ctx, { id: message.id, type: MessageType.Next, @@ -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(ctx, { id: message.id, type: MessageType.Next,