Open stalniy opened 7 years ago
The code needs to be changed to super.watchQuery.bind(this)
or (...args) => super.watchQuery(...args)
If you use apollo-angular then we changed the way ApolloClient works with RxJS. You can check it here: apollographql/apollo-angular#377
No more this kind of issues.
Steps:
RxApolloClient
classapollo.watchQuery({ query, variables })
Actual result Exception is thrown: core.es5.js:1084 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'initStore' of undefined TypeError: Cannot read property 'initStore' of undefined at ApolloClient.watchQuery (ApolloClient.js:179) at SwitchMapSubscriber.project (variables.js:14) at SwitchMapSubscriber._next (switchMap.js:88) at SwitchMapSubscriber.Subscriber.next (Subscriber.js:89) at SafeSubscriber._next
Expected result No errors
Context: digging into source code I see that watchQuery is passed without bound "this" context. That's why after calling it, function throws an error