From bfd2ddf8ba5f8be03a6af5e00e06b83e81bcbf65 Mon Sep 17 00:00:00 2001 From: Stephan Meijer Date: Wed, 30 Sep 2020 12:18:32 +0200 Subject: [PATCH] feat: pass `res` to contextResolver This will enable us to use the response object in the function that creates the context. This can for example be used to bind (logging) events with `res.once('finish', () => {})` --- server/initialize.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/initialize.js b/server/initialize.js index b721e17..2f20e87 100644 --- a/server/initialize.js +++ b/server/initialize.js @@ -90,7 +90,7 @@ function getContextCreator(meteorApolloConfig, initialApolloConfig) { } = initialApolloConfig; const baseContext = { db }; - return async function getContext({ req: request, connection }) { + return async function getContext({ req: request, res, connection }) { // This function is called whenever a normal graphql request is being made, // as well as when a client initiates a new subscription. However, when a // client subscribes, the request headers are not being send along. The @@ -112,6 +112,7 @@ function getContextCreator(meteorApolloConfig, initialApolloConfig) { const defaultContext = defaultContextResolver ? await defaultContextResolver({ req, + res, connection, ...baseContext, ...userContext,