Skip to content

Commit

Permalink
feat: pass res to contextResolver
Browse files Browse the repository at this point in the history
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', () => {})`
  • Loading branch information
smeijer authored Sep 30, 2020
1 parent 142d4e1 commit bfd2ddf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -112,6 +112,7 @@ function getContextCreator(meteorApolloConfig, initialApolloConfig) {
const defaultContext = defaultContextResolver
? await defaultContextResolver({
req,
res,
connection,
...baseContext,
...userContext,
Expand Down

0 comments on commit bfd2ddf

Please sign in to comment.