Skip to content
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

Add observable query current result #709

Merged
merged 6 commits into from
Sep 29, 2016

Conversation

tmeasday
Copy link
Contributor

@tmeasday tmeasday commented Sep 26, 2016

This PR is rebased from #635.

It also should not be merged until we've confirmed with RA.

@tmeasday tmeasday changed the base branch from master to add-observable-query-setVariables September 26, 2016 07:42
@helfer
Copy link
Contributor

helfer commented Sep 29, 2016

@tmeasday would you like to see this merged+published before or after our refactor?

@tmeasday
Copy link
Contributor Author

Ideally before I think. Let me hassle @jbaxleyiii again, as he was going to look at this stuff

@jbaxleyiii
Copy link
Contributor

@tmeasday @helfer I'm so sorry for the delayed response on this. Especially since @tmeasday killed it here and with RA. I'm all for it!

@tmeasday
Copy link
Contributor Author

Good to go then @helfer

Also added a test to ensure that we are loading during refetches
(If the results are in the store and `returnPartialData` is used)
And returns the correct "loading" indicator in all cases.

The primary aim here is to return results synchronously, even if the query fetch hasn't executed yet. So `currentResult` needs to figure out if a network fetch will be necessary.
@tmeasday tmeasday force-pushed the add-observable-query-current-result branch from 420d14c to 2f2bb33 Compare September 29, 2016 09:56
@tmeasday tmeasday changed the base branch from add-observable-query-setVariables to master September 29, 2016 09:56
@tmeasday
Copy link
Contributor Author

tmeasday commented Sep 29, 2016

@helfer - rebased against master.

I actually ended up undoing part of this commit: https://github.com/apollostack/apollo-client/pull//commits/d852946123ccf2c6f5496a60924a67d89a5954c5

My rationale is that QueryManager.getCurrentQueryResult (and things in general) shouldn't need to look at the state of the query in order to figure out what the results of the query are. It's problematic for a few reasons, one in particular is: what if you call it before the query has even initialized, and the state is null? (which I do from observable.currentResult() if you call it right after creating the query).

The state of the query should be irrelevant to the results of the query. It's only the options etc of the query that determine the results. (The state drives loading--and networkStatus later--though of course).

I'm not sure if we should remove the rest of the above commit too? Do we use queryState.stopped for anything else? Probably something for you and @stubailo to look at during the refactor.

Obviously the tests from that #696 are super helpful to have, and still pass in this branch!

cc @rricard

@helfer
Copy link
Contributor

helfer commented Sep 29, 2016

@tmeasday yeah, I think we'll remove the stopped state in the refactor, but I'll publish a version with this first.

@helfer helfer merged commit 1398cd3 into master Sep 29, 2016
@rricard rricard deleted the add-observable-query-current-result branch September 29, 2016 23:34
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants