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

useLazyQuery / useQuery hook still isn't fired after fetching data from the cache #3488

Closed
Hianz opened this issue Sep 12, 2019 · 1 comment · Fixed by #3497
Closed

useLazyQuery / useQuery hook still isn't fired after fetching data from the cache #3488

Hianz opened this issue Sep 12, 2019 · 1 comment · Fixed by #3497

Comments

@Hianz
Copy link

Hianz commented Sep 12, 2019

Intended outcome:

OnCompleted should be called after query result is fetched.
The problem appears to be solved only with the component as stated here:
#2177
With the useQuery or useLazyQuery hooks the problem still appears.

If i set { fetchPolicy: "no-cache" } for the query the onCompleted will be called as expected.

Actual outcome:
onCompleted is only called after the first call/render. On any subsequent calls it is not invoked.

How to reproduce the issue:
Here is a sandbox to reproduce the problem: https://codesandbox.io/s/vigilant-maxwell-gqyf2?fontsize=14

onCompleted is only called after the first call to Load() as shown in the console.

Version
react-apollo: v3.1.0 release

@Hianz Hianz changed the title Query.onCompleted isn't fired after fetching data from the cache useLazyQuery / useQuery hook still isn't fired after fetching data from the cache Sep 12, 2019
@Hianz
Copy link
Author

Hianz commented Sep 12, 2019

#3361

hwillson added a commit that referenced this issue Sep 15, 2019
Make sure `onCompleted` is called each time a `useLazyQuery` based
query completes, after the execution function is called.

Fixes #3488
hwillson added a commit that referenced this issue Sep 15, 2019
Make sure `onCompleted` is called each time a `useLazyQuery` based
query completes, after the execution function is called.

Fixes #3488
hwillson added a commit that referenced this issue Sep 15, 2019
Make sure `onCompleted` is called each time a `useLazyQuery` based
query completes, after the execution function is called.

Fixes #3488
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 a pull request may close this issue.

1 participant