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

LazyQuery does not pickup data from cache #9544

Closed
jeremymelchor opened this issue Mar 22, 2022 · 2 comments · Fixed by #9564
Closed

LazyQuery does not pickup data from cache #9544

jeremymelchor opened this issue Mar 22, 2022 · 2 comments · Fixed by #9564
Assignees
Milestone

Comments

@jeremymelchor
Copy link

I don't know if this is a known issue, I don't even know if it is an issue but I found that when you use LazyQuery in the following way, it never read the cache, even when you put a fetchPolicy: 'cache-only'.

Example: (I initially did this because I needed to fetch the userEmail to use it as a variable)

function Component() {
  const [doQuery, queryResult] = useLazyQuery(query);

  useEffect(() => {
    (async () => {
      const userEmail = await fetchUserEmail();
      doQuery({variables: {userEmail}});
    })();
  }, []);
}
@benjamn benjamn self-assigned this Mar 25, 2022
@benjamn benjamn added this to the Release 3.6 milestone Mar 25, 2022
@benjamn
Copy link
Member

benjamn commented Apr 5, 2022

@patchimou Can you try the latest v3.6 beta by running npm i @apollo/client@beta when you have a chance? I believe PR #9564 will help here (if your issue is similar to #9375).

@jeremymelchor
Copy link
Author

@benjamn I just tried and I can confirm you it works fine ! No additional networks calls are made after the 1st one.
Thank you for your time

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants