Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Fix query result when skip=true (#1869) #1916

Merged
merged 8 commits into from
Sep 19, 2018
Merged

Conversation

edorivai
Copy link
Contributor

@edorivai edorivai commented Apr 9, 2018

Should fix #1869

I added a test case, and took the implementation from the original PR that aimed to implement the skip prop on <Query>.

I suspect this piece of logic got lost in the big rewrite mentioned here.

Checklist:

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • If this was a change that affects the external API used in GitHunt-React, update GitHunt-React and post a link to the PR in the discussion.

@edorivai
Copy link
Contributor Author

edorivai commented Apr 10, 2018

Not sure what's up with that failing test. Is it because of the changes in this PR?

@ZwaarContrast
Copy link

Any progress on this?

@caseywebdev
Copy link

Ran into this issue yesterday, can a maintainer chime in here? I really like the Query component but I also need the skip and loading values to work correctly 😉

@k00k
Copy link

k00k commented May 7, 2018

@edorivai care to merge master back in? Any idea what we need to do to get this PR merged?

@edorivai
Copy link
Contributor Author

edorivai commented May 8, 2018

@k00k I've merged back in, seems like all checks passed. As far as I know this PR should be good to go.

@hwillson hwillson self-assigned this Jun 19, 2018
Copy link

@k00k k00k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All checks pass. Looks clean.

src/Query.tsx Outdated
// When skipping a query (ie. we're not querying for data but still want
// to render children), make sure the `data` is cleared out and
// `loading` is set to `false` (since we aren't loading anything).
if (this.props.skip) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick note here - I've re-arranged this a bit to short circuit un-necessary extra query logic, when the query is to be skipped. One thing to add though, is that this means we're leaving networkStatus as undefined. This is currently intentional, as setting this to NetworkStatus.ready can cause problems when using something like the graphql hoc and calculating the skip value using a function (forcing a NetworkStatus.ready value can prematurely end rendering). Leaving networkStatus as undefined here seems to be okay though, and is better than the way it was before when we did the skip check at the end of getQueryResult. That left networkStatus in NetworkStatus.loading state, even though we weren't loading anything.

@caseywebdev
Copy link

What's the status on this one? Seems like it's good to go (besides conflicts).

@miafoo
Copy link

miafoo commented Jul 10, 2018

We've run into this issue as well and would really appreciate it being merged in. 😃

@rosskevin
Copy link
Contributor

Please resolve conflicts, otherwise I think this good to merge

@edorivai
Copy link
Contributor Author

@hwillson are you picking up the conflicts, or would you like me to do it?

@hwillson
Copy link
Member

@edorivai I'll take care of it shortly. Thanks!

@stephane-ruhlmann
Copy link

Is anyone taking care of this?

@Kjagd
Copy link

Kjagd commented Sep 4, 2018

@hwillson What's the status on this? We've been greatly affected by this for quite some time now.

@pascalstr
Copy link

@hwillson what is the status of resolving these conflicts and merging this PR?

Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're good to go here @edorivai - sorry for the long delay, and thanks for working on this!

@hwillson hwillson merged commit bab1a88 into apollographql:master Sep 19, 2018
@edorivai
Copy link
Contributor Author

Great to hear 🎉

@sbogdaniuk
Copy link

SO you just fixed this issue for Component, and for HOC not, right?

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.

Loading true when skipped