Closed dairyisscary closed 2 years ago
@dairyisscary Can you try npm i @apollo/client@beta
to install version 3.7.0-alpha.2
? That version includes #9666, which I think may help with this issue. If that solves your problem, then we will release 3.6.3 with the same changes.
@benjamn thanks for getting back so quickly!
No, unfortunately, I can still reproduce on 3.7.0-alpha.2
. Again, not sure if this is helpful at all but that !equal()
check is not protecting the reobserve
call in this case on the first re-render post-click.
@dairyisscary Can you try putting the relevant code into a runnable reproduction? I'll keep trying things on my side, but a reproduction helps a ton.
@benjamn https://github.com/dairyisscary/duplicate-lazy-query main branch has it
I struggled at first to reproduce it so I kept adding more and more of my configuration until I got it. it was the queryDeduplication: false
on the Client constructor. sorry homie; completely forgot about this setting since its fire and forget. :)
I'm less certain this is a bug now but i will say on apollo 3.4.17
this does not duplicate the network request twice even with queryDeduplication
turned off (I'm two releases behind, I never got to 3.5). if it is not a bug, what would you recommend benjamn? there doesn't appear to be a way to turn this on and off for an individual query -- I would turn it off for this particular query if it were possible.
This is definitely something we (still) want to fix @dairyisscary! Thanks for the reproduction. 🙌
@dairyisscary Figured it out (I think)!
@dairyisscary This should be fixed if you run npm i @apollo/client@next
(to get version 3.6.3)!
amazing, seems to fix the issue in real app. thanks @benjamn!
I have some code like this:
I click the button (once) but see two queries in the network tab. If i click the button a second time, with new
something
, the query appears to only fire one more time, as expectedIn my debugging, I found that this line is executing the query for the same variables and same options passed to
useLazyQuery
: https://github.com/apollographql/apollo-client/blob/76ad8a789a20a4962270649dfe5e5fbcfbf9c0fa/src/react/hooks/useQuery.ts#L215for me, the second extra query has this:
Hopefully this is helpful and not just a red herring :)