Skip to content

prioritizeCacheValues and prerenderStatic-related fixes#13105

Merged
phryneas merged 18 commits intomainfrom
pr/prioritizeCacheValues-standby
Jan 21, 2026
Merged

prioritizeCacheValues and prerenderStatic-related fixes#13105
phryneas merged 18 commits intomainfrom
pr/prioritizeCacheValues-standby

Conversation

@phryneas
Copy link
Copy Markdown
Member

@phryneas phryneas commented Jan 19, 2026

Fixes #13102 and a few other findings I had along the way. It also adds a bunch of tests for these and related scenarios.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 19, 2026

🦋 Changeset detected

Latest 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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Jan 19, 2026

npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@13105

commit: 02bc1af

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 prioritizeCacheValues to only transform network-only and cache-and-network fetch policies to cache-first, preserving the behavior of other policies like no-cache, cache-only, and standby
  • Added support for skipToken in useSSRQuery to properly skip queries during SSR
  • Enhanced useSSRQuery to skip fetches when fetchPolicy: '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.

@apollo-librarian
Copy link
Copy Markdown

apollo-librarian bot commented Jan 19, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 6989b539ad5e9f1595376986
Build Logs: View logs

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@phryneas phryneas marked this pull request as ready for review January 19, 2026 14:02
@github-actions github-actions bot added the auto-cleanup 🤖 label Jan 20, 2026
@phryneas phryneas merged commit 8b62263 into main Jan 21, 2026
33 checks passed
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
phryneas pushed a commit that referenced this pull request Jan 21, 2026
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>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

loading state always true when ssrForceFetchDelay is used

3 participants