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

[3.0-beta] Changing skip to true on a hook ignores results from "fast" data sources #5877

Closed
panrafal opened this issue Jan 29, 2020 · 0 comments · Fixed by #6587
Closed

Comments

@panrafal
Copy link

In a situation where:

  • we use a hook with skip: true
  • we switch the skip to false
  • the link responds without a delay (it may be a Promise, but it cannot use setTimeout) - like a caching mechanism, mock, etc.

Intended outcome:
The query is executed and results are displayed

Actual outcome:
The query is executed, but results are not displayed - they're "loading" forever
Switching the skip again to true and false again works as intended.

How to reproduce the issue:
See this sandbox for a reproduction:
https://codesandbox.io/s/goofy-spence-0l96j

Click the toggle skip - you should see the results, but you'll see the "Loading..." screen. If you change the version of the package to beta.14 - it will work again.

Versions
3.0.0-beta.29
The 3.0.0-beta.14 works as expected, so regression was introduced in beta.15.

Potential Solution
I was able to fix this by checking this.options.skip in this line instead:
https://github.com/apollographql/apollo-client/blob/master/src/react/data/QueryData.ts#L296

Currently, when the result of the query arrives, the previousOptions still holds skip: true - therefore the result is ignored. previousOptions are set by the hook with afterExecute, but it seems that this is too late for this skipping logic to work as intended.

@benjamn benjamn added this to the Release 3.0 milestone Jan 29, 2020
@hwillson hwillson self-assigned this Jul 10, 2020
hwillson added a commit that referenced this issue Jul 13, 2020
Recent Apollo Client core refactoring has made it unnecessary
to attempt to block duplicate `useQuery` renders when `skip`
is `true`.

Fixes #5877
hwillson added a commit that referenced this issue Jul 13, 2020
Recent Apollo Client core refactoring has made it unnecessary
to attempt to block duplicate `useQuery` renders when `skip`
is `true`.

Fixes #5877
hwillson added a commit that referenced this issue Jul 13, 2020
Recent Apollo Client core refactoring has made it unnecessary
to attempt to block duplicate `useQuery` renders when `skip`
is `true`.

Fixes #5877
benjamn pushed a commit that referenced this issue Jul 13, 2020
Recent Apollo Client core refactoring has made it unnecessary
to attempt to block duplicate `useQuery` renders when `skip`
is `true`.

Fixes #5877
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants