-
-
Notifications
You must be signed in to change notification settings - Fork 311
Query's variables as Observables #64
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
Conversation
b76e2d1 to
2c82d30
Compare
|
Done but it seems like there is an issue with apollographql/apollo-client#535 Also a problem with missing apollo-specific method (like refetch) after |
5b1c9c4 to
48322f0
Compare
|
Seems like the problem with missing apollo-specific methods has been solved. |
10f2c09 to
3c958d2
Compare
|
Possible cases: All variables as Subjects import { Subject } from 'rxjs/Subject';
const name = new Subject();
const city = new Subject();
const obs = client.watchQuery({
query,
variables: {
name,
city
}
});
obs.subscribe(result => {
console.log(result);
});
// waits for values to be emitted
name.next('Kamil');
// still waits
city.next('Warsaw'); // builds the query with {name: 'Kamil', city: 'Warsaw' }Mixed import { Subject } from 'rxjs/Subject';
const name = new Subject();
const obs = client.watchQuery({
query,
variables: {
name,
city: 'Warsaw'
}
});
obs.subscribe(result => {
console.log(result);
});
// waits for values to be emitted
name.next('Kamil'); // builds the query with {name: 'Kamil', city: 'Warsaw' }No Subjects const name = 'Kamil';
const obs = client.watchQuery({
query,
variables: {
name,
city: 'Warsaw'
}
});
obs.subscribe(result => {
console.log(result);
});
// builds the query with {name: 'Kamil', city: 'Warsaw' } |
3c958d2 to
9f73d32
Compare
|
This is so awesome @kamilkisiela |
|
@jbaxleyiii Any suggestions about the implementation? It might be the final solution but I'm still waiting to merge it. I was thinking to implement it in ApolloClient, somehow. |
|
I was also thinking about writing a blog post about it. |
|
@kamilkisiela Definitely +1 on the blog post. |
|
@robwormald would love to get your take on this |
| const cleanOptions = omit(options, 'variables'); | ||
| const newOptions = assign(cleanOptions, { variables: newVariables }); | ||
|
|
||
| apolloRef.apollo = this.client.watchQuery(newOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kamilkisiela would it be better to do a refetch with the new variables instead of creating a new query here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbaxleyiii I don't know if it would work with switchMap, I'll take a look on this.
|
@kamilkisiela notes added! |
|
Docs added apollostack/docs#173 |
Closes #62
Example: