Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Call onCompleted with data from cache #2190

Merged
merged 3 commits into from
Sep 21, 2018

Conversation

olistic
Copy link
Contributor

@olistic olistic commented Jul 17, 2018

This is a first attempt to fix #2177. If there's data at the time the Query component mounts, onCompleted will be called.

I'm not sure if this is the right direction. If anyone could take a look and let me know what they think I'd really appreciate it. If the changes are good, I'll put some effort into fixing the tests and writing new ones.

Thanks!

@hwillson
Copy link
Member

Thanks for taking an initial pass at this @olistic! I'm going to make a few adjustments to this PR, then we'll get this merged shortly.

@hwillson hwillson self-assigned this Sep 20, 2018
@olistic
Copy link
Contributor Author

olistic commented Sep 21, 2018

@hwillson Cool! If there's anything else I could do to help, it'd be a pleasure. Just let me know, and anyway, I'll keep an eye on the PR so I learn a bit more about the codebase.

Adjusts `<Query />` `onCompleted` and `onError` callbacks to be
triggered via the `componentDidUpdate` lifecycle method. This
ensures these callbacks can be used when data is fetched over
the network, and when data is fetched from the local store
(previsouly these callbacks were only being triggered when data
was fetched over the network).
@kandros
Copy link
Contributor

kandros commented Oct 19, 2018

I spent like 10 hours finding the cause of a regression caused by this 😔

Apollo is not using semver?

This should have been either marked as a breaking change or be opt-in via prop considering there is no way to keep the previous behaviour

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query.onCompleted isn't fired after fetching data from the cache
3 participants