prioritizeCacheValues and prerenderStatic-related fixes#13105
prioritizeCacheValues and prerenderStatic-related fixes#13105
prioritizeCacheValues and prerenderStatic-related fixes#13105Conversation
🦋 Changeset detectedLatest commit: 4e0fd2c The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
There was a problem hiding this comment.
Pull request overview
This PR fixes issues related to prioritizeCacheValues and prerenderStatic by ensuring that certain fetch policies and skip conditions are properly respected during SSR and when cache values are prioritized.
Changes:
- Fixed
prioritizeCacheValuesto only transformnetwork-onlyandcache-and-networkfetch policies tocache-first, preserving the behavior of other policies likeno-cache,cache-only, andstandby - Added support for
skipTokeninuseSSRQueryto properly skip queries during SSR - Enhanced
useSSRQueryto skip fetches whenfetchPolicy: 'no-cache'is specified
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/react/ssr/useSSRQuery.ts |
Added skipToken handling and fetchPolicy: 'no-cache' check to avoid fetches during SSR |
src/core/ObservableQuery.ts |
Refined prioritizeCacheValues logic to only transform network-only and cache-and-network policies |
src/react/ssr/__tests__/prerenderStatic.test.tsx |
Added comprehensive tests for skipToken, fetchPolicy: 'no-cache', fetchPolicy: 'standby', and ssr: false scenarios |
src/react/hooks/__tests__/useQuery.test.tsx |
Refactored and expanded tests for prioritizeCacheValues with all fetch policy combinations |
src/core/__tests__/ObservableQuery.ts |
Added comprehensive tests verifying prioritizeCacheValues behavior with different fetch policies at the ObservableQuery level |
.changeset/nervous-tables-develop.md |
Changeset documenting fix for fetchPolicy: 'no-cache' with prerenderStatic |
.changeset/empty-berries-greet.md |
Changeset documenting fix for skipToken with prerenderStatic |
.changeset/angry-trees-sniff.md |
Changeset documenting fix for prioritizeCacheValues respecting all fetch policies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 6989b539ad5e9f1595376986 |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @apollo/[email protected] ### Patch Changes - [#13105](#13105) [`8b62263`](8b62263) Thanks [@phryneas](https://github.com/phryneas)! - `ssrMode`, `ssrForceFetchDelay` or `prioritizeCacheValues` should not override `fetchPolicy: 'cache-only'`, `fetchPolicy: 'no-cache'`, `fetchPolicy: 'standby'`, `skip: true`, or `skipToken` when reading the initial value of an `ObservableQuery`. - [#13105](#13105) [`8b62263`](8b62263) Thanks [@phryneas](https://github.com/phryneas)! - Fix `skipToken` in `useQuery` with `prerenderStatic` and related SSR functions. - [#13105](#13105) [`8b62263`](8b62263) Thanks [@phryneas](https://github.com/phryneas)! - Avoid fetches with `fetchPolicy: no-cache` in `useQuery` with `prerenderStatic` and related SSR functions. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fixes #13102 and a few other findings I had along the way. It also adds a bunch of tests for these and related scenarios.