-
-
Save tgriesser/49674e0062b700eb43e93aacd724c3e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/graphql/subscription/subscribe.d.ts b/node_modules/graphql/subscription/subscribe.d.ts | |
index a2a2d08..d6e9a66 100644 | |
--- a/node_modules/graphql/subscription/subscribe.d.ts | |
+++ b/node_modules/graphql/subscription/subscribe.d.ts | |
@@ -16,6 +16,7 @@ export interface SubscriptionArgs { | |
operationName?: Maybe<string>; | |
fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | |
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>; | |
+ contextValueExecution?: (contextValue?: any) => any; | |
} | |
/** | |
diff --git a/node_modules/graphql/subscription/subscribe.js b/node_modules/graphql/subscription/subscribe.js | |
index d4f0d94..c264305 100644 | |
--- a/node_modules/graphql/subscription/subscribe.js | |
+++ b/node_modules/graphql/subscription/subscribe.js | |
@@ -63,7 +63,8 @@ function subscribeImpl(args) { | |
variableValues = args.variableValues, | |
operationName = args.operationName, | |
fieldResolver = args.fieldResolver, | |
- subscribeFieldResolver = args.subscribeFieldResolver; | |
+ subscribeFieldResolver = args.subscribeFieldResolver, | |
+ contextValueExecution = args.contextValueExecution || contextValue; | |
var sourcePromise = createSourceEventStream(schema, document, rootValue, contextValue, variableValues, operationName, subscribeFieldResolver); // For each payload yielded from a subscription, map it over the normal | |
// GraphQL `execute` function, with `payload` as the rootValue. | |
// This implements the "MapSourceToResponseEvent" algorithm described in | |
@@ -72,7 +73,9 @@ function subscribeImpl(args) { | |
// "ExecuteQuery" algorithm, for which `execute` is also used. | |
var mapSourceToResponse = function mapSourceToResponse(payload) { | |
- return (0, _execute.execute)(schema, document, payload, contextValue, variableValues, operationName, fieldResolver); | |
+ var execCtxValue = typeof contextValueExecution === 'function' ? contextValueExecution(contextValue) : contextValueExecution | |
+ | |
+ return (0, _execute.execute)(schema, document, payload, execCtxValue, variableValues, operationName, fieldResolver); | |
}; // Resolve the Source Stream, then map every source value to a | |
// ExecutionResult value as described above. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment