react-apollo
react-apollo copied to clipboard
query onCompleted not firing when requesting the same data twice
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
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?
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.
Facing the same issue
+1
Having the same issue. Now I try to fix it by removing cache.