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<
TData,
TSubscriptionVariables,
TSubscriptionData
>,
) {
const subscription = this.queryManager
.startGraphQLSubscription({
query: options.document,
variables: options.variables,
- context: options.context,
+ context: options.context || _this.options.context,
})