Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

When the context is patched outside of apollo-client, then subscribeToMore doesn't inherit this context by Query with the current solution.

Our application wraps all queries and extends their context with services and some extra data. However, it isn't possible to easily wrap subscribeToMore, because it is made with its own empty context inside the ObservableQuery. For this reason, when we want to use these data inside the subscription, we are not able to do so.

Currently, the only way is to use links, but would the following change be a valid resolution of this problem ?

// src/core/ObservableQuery.ts  

public subscribeToMore< 
      TSubscriptionData = TData, 
      TSubscriptionVariables = TVariables 
      options: SubscribeToMoreOptions< 
    ) { 
      const subscription = this.queryManager 
          query: options.document, 
          variables: options.variables, 
-        context: options.context, 
+        context: options.context || _this.options.context, 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment