react-apollo icon indicating copy to clipboard operation
react-apollo copied to clipboard

query onCompleted not firing when requesting the same data twice

Open himat opened this issue 4 years ago • 5 comments

Intended outcome:

Every time I call getData(), the onCompleted should fire, but it is not. I don't even see a network call in chrome either, so it seems like the data is being gotten from the cache, but even then, in theory, onCompleted should ALWAYS be called.

const [getData, {loading, data, error }] = useLazyQuery(QUERY,
  {
   onCompleted: (dObj) => {
      console.log("onCompleted ", dObj);
    }
});

Actual outcome:

Nothing is printed sometimes, until I make a query for a different data object, and then retry the original request.

How to reproduce the issue:

https://github.com/apollographql/react-apollo/issues/2177#issuecomment-609647346

Version

 System:
   OS: macOS Mojave 10.14.5
 Binaries:
   Node: 13.8.0 - /usr/local/bin/node
   Yarn: 1.16.0 - /usr/local/bin/yarn
   npm: 6.13.7 - /usr/local/bin/npm
 Browsers:
   Chrome: 80.0.3987.163
   Firefox: 74.0.1
   Safari: 12.1.1
 npmPackages:
   @apollo/react-hooks: ^3.1.3 => 3.1.3
   apollo-boost: ^0.4.7 => 0.4.7
   apollo-link-ws: ^1.0.19 => 1.0.19
   react-apollo: ^3.1.3 => 3.1.3

himat avatar Apr 11 '20 21:04 himat

Running in the same issue. Have red a lot of other issues regarding this topic. Seems like it is "still not fixed yet". Is it even worth concering to update my whole production app to Apollo Client v3 even if it's in beta?

beeirl avatar Apr 12 '20 11:04 beeirl

I am also having the exact same issue. useLazyQuery, onCompleted method does not fire when loading data from cache. Tried with @apollo/client : 3.0.0-beta.43 and @apollo/react-hooks: 3.1.4.

jamie-oconnell avatar Apr 13 '20 15:04 jamie-oconnell

Facing the same issue

KKzLEO avatar Apr 14 '20 03:04 KKzLEO

+1

jspantheonlab avatar Apr 24 '20 02:04 jspantheonlab

Having the same issue. Now I try to fix it by removing cache.

vdanny avatar Apr 29 '20 05:04 vdanny