Skip to content

Commit

Permalink
Merge pull request #9504 from apollographql/avoid-full-reobservation-…
Browse files Browse the repository at this point in the history
…after-fetchMore

Avoid full reapplication of `cache-and-network` and `network-only` fetch policies after successful `fetchMore`
  • Loading branch information
benjamn committed Mar 29, 2022
2 parents 0249c8b + 5036dc5 commit f6fb1ec
Show file tree
Hide file tree
Showing 7 changed files with 1,060 additions and 277 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
- Provide additional context to `nextFetchPolicy` functions to assist with `fetchPolicy` transitions. More details can be found in the [`nextFetchPolicy` documentation](https://deploy-preview-9067--apollo-client-docs.netlify.app/data/queries/#nextfetchpolicy). <br/>
[@benjamn](https://github.com/benjamn) in [#9222](https://github.com/apollographql/apollo-client/pull/9222)

- Remove nagging deprecation warning about passing an `options.updateQuery` function to `fetchMore`. <br/>
[@benjamn](https://github.com/benjamn) in [#9504](https://github.com/apollographql/apollo-client/pull/9504)

### Potentially disruptive changes

- Calling `fetchMore` for queries using the `cache-and-network` or `network-only` fetch policies should no longer trigger additional network requests when cache results are complete. <br/>
[@benjamn](https://github.com/benjamn) in [#9504](https://github.com/apollographql/apollo-client/pull/9504)

### Postponed to v3.7

- Tentatively reimplement `useQuery` and `useLazyQuery` to use the [proposed `useSyncExternalStore` API](https://github.com/reactwg/react-18/discussions/86) from React 18. <br/>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{
"name": "apollo-client",
"path": "./dist/apollo-client.min.cjs",
"maxSize": "29kB"
"maxSize": "29.2kB"
}
],
"engines": {
Expand Down
5 changes: 1 addition & 4 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3374,12 +3374,9 @@ describe('@connection', () => {
} else if (handleCount === 4) {
expect(result.data).toEqual({ count: "secondary" });
expect(nextFetchPolicyCallCount).toBe(3);
client.cache.evict({ fieldName: "count" });
} else if (handleCount === 5) {
expect(result.data).toEqual({ count: 1 });
expect(nextFetchPolicyCallCount).toBe(3);
client.cache.evict({ fieldName: "count" });
} else if (handleCount === 6) {
expect(result.data).toEqual({ count: 2 });
expect(nextFetchPolicyCallCount).toBe(4);
expect(obs.options.fetchPolicy).toBe("cache-first");
setTimeout(resolve, 50);
Expand Down
Loading

0 comments on commit f6fb1ec

Please sign in to comment.