-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move refetch(), startPolling() and stopPolling() from Subscription to ObservableQuery #194
Comments
@martijnwalraven I'm all for it! |
@Urigo, @kamilkisiela I think we should fix this ASAP. I was just talking to @purban and it's a bit weird because people from Angular 2 are going to be expecting RxJS, not a regular old observable. With this merged, at least we can implement a feature to replace the observable shim with Rx. |
Move methods to observable (Issue #194)
Maybe you guys will be interested in it. Here's an implementation of import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/from';
const origin = client.watchQuery(options); // QueryObservable
const obs = Observable.from(origin);
origin.refetch(); // works
obs.refetch(); // refetch is undefined
obs.ish.refetch(); // works (it should) because `ish` is a reference to `origin` To solve that problem I created a custom observable called import 'rxjs';
import { ApolloQueryObservable } from 'angular2-apollo';
const origin = client.watchQuery(options); // QueryObservable
const obs = new ApolloQueryObservable(origin);
origin.refetch(); // works
obs.refetch(); // works
obs.map(customMapFunction).refetch() // refetch is undefined As you can see, it still won't work with operators. Here's why. Every operator uses
I solved this by overwriting @stubailo @martijnwalraven @jbaxleyiii @Urigo I was thinking about moving this |
Hmm, sounds like this could be a good idea. Could you open a new issue with some details about how |
The url was pointing to the graphql endpoint, not the GraphiQL ide
Interoperability with other Observable implementations (see #149) means we have no control over the Subscription object users end up with.
For example,
Rx.Observable.from(handle).subscribe()
would return an RxJS Subscription object without the Apollo-specific helper methods.So I think it makes most sense to move these methods to
ObservableQuery
(maybe this needs a better name, likeQueryHandle
or simplyQuery
).This will require some refactoring of the current code to share fetching and polling logic between observers, but that actually seems like a better design anyway.
The text was updated successfully, but these errors were encountered: