useLazyQuery with the same document as useQuery triggers onCompleted for the latter
A simple question i think, i don't know if this is on purpose.
I have a table, for which I use useQuery to get it's data, paginated, on load, but then I have a button in a menu, where I want to fetch all the available records from the backend to print to CSV, the problem is that when I execute the useLazyQuery (using the same document but with more records requested) the call is fine, but the onCompleted of the original useQuery is executed too, I can't find a way to prevent this from happening, maybe if I had some flag I can use there to say "don't do what it's in here since the call was from another hook"?
Any ideas?
+1
Also if I use two useLazyQuery on the same app page I get infinite loop. Response from the second useLazyQuery triggers the first useLazyQuery and the first useLazyQuery triggers the second useLazyQuery and so on. I believe this case is probably related to situation above.
@jbaccarelli-equinix Can you share some example code of how you set this up?
Hey @jbaccarelli-equinix 👋
I believe what you're seeing was due to the fact that onCompleted was triggered by cache writes. We fixed this in 3.8.0 via https://github.com/apollographql/apollo-client/pull/10340. Try upgrading to 3.8.0 or greater.
As such, I'm going to go ahead and close this out. Feel free to reopen if I've made a mistake!
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.