Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify fetchMore loading result simulation.
PR #6221 began enforcing fetch policies more consistently/literally in response to cache updates (so we do not accidentally skip network requests that are required by policy). That consistency has been valuable, but there are some exceptions where we want to deliver a single result from the cache, but we do not want to use the fetchQueryObservable system to deliver it, because we do not want the delivery to have the side effect of triggering a network request under any circumstances, regardless of the fetch policy. For example, we want to deliver a { loading: true, networkStatus: NetworkStatus.fetchMore } result for the original query at the beginning of a fetchMore request (see #6583), but that one-off result should not cause the original query to fire a network request if the cache data happens to be incomplete, because that would likely interfere with the fetchMore network request. At the time I implemented #6583, it was the only exception that I knew of, so I kept things simple and fetchMore-specific. I've since found another example (not fetchMore-related this time), so I think it's time to make this pattern more official. Hence ObservableQuery#observe, whose name is meant to draw a contrast with the ObservableQuery#reobserve method. The observe method simply delivers the latest result known to the ObservableQuery, reading from the cache if necessary, whereas reobserve reapplies the chosen fetch policy, possibly making network requests.
- Loading branch information