Skip to content

Conversation

@nygrenh
Copy link
Member

@nygrenh nygrenh commented Jan 9, 2026

Summary by CodeRabbit

  • Enhancements
    • Added an option to skip server-side data fetching for Apollo Client, giving pages finer control over SSR data initialization.
    • Enabled opting out of server-side rendering for specific pages by wrapping them with a no-SSR helper, preventing SSR for those routes.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Adds a skipSsrFetch boolean propagated through the with-apollo-client HOC and get-apollo factory. When true on the server, the Apollo client uses a skipSsrFetchLink that emits null data to bypass SSR fetching. The flag is passed through client initialization and returned in HOC props.

Changes

Cohort / File(s) Summary
Apollo client factory
frontend/lib/with-apollo-client/get-apollo.ts
Adds skipSsrFetch parameter to create and getApollo; when skipSsrFetch is true on server, switches to skipSsrFetchLink (emits null) instead of standard ApolloLink.from.
Apollo HOC & SSR propagation
frontend/lib/with-apollo-client/index.tsx
Adds skipSsrFetch?: boolean to Props; computes and propagates skipSsrFetch in SSR paths, passes it to getApollo, and includes it in returned HOC props.
Pages — disable SSR via wrapper
frontend/pages/index.tsx, frontend/pages/study-modules/index.tsx
Wraps default exports with withNoSsr(...) to disable SSR for these pages (imports withNoSsr and changes export).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I nibble bytes at break of dawn,
Hop past SSR where waits the lawn,
skipSsrFetch lets data rest,
Links skip fetching, I bounce best,
Hooray — the client springs along! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Reduce fetching during ssr' accurately describes the main objective of the pull request, which adds a skipSsrFetch feature to skip data fetching during server-side rendering across multiple components and the Apollo client wrapper.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.31%. Comparing base (d7a95a7) to head (0a73095).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1304      +/-   ##
==========================================
+ Coverage   61.98%   66.31%   +4.33%     
==========================================
  Files         150      154       +4     
  Lines        6355     6460     +105     
  Branches     1577     1591      +14     
==========================================
+ Hits         3939     4284     +345     
+ Misses       2259     2037     -222     
+ Partials      157      139      -18     
Flag Coverage Δ
backend 66.31% <ø> (+4.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/lib/with-apollo-client/get-apollo.ts (1)

300-302: Add skipSsrFetch parameter to initNewApollo.

The initNewApollo function should accept and propagate the skipSsrFetch parameter to maintain consistency with the underlying create() function and the getApollo() initialization function, which both support this parameter.

Update the function signature and call:

export function initNewApollo(accessToken?: string, locale?: string, skipSsrFetch?: boolean) {
  apolloClient = create(undefined, accessToken, locale, skipSsrFetch)
  return apolloClient
}
🤖 Fix all issues with AI agents
In @frontend/lib/with-apollo-client/index.tsx:
- Around line 72-78: The current logic sets skipSsrFetch = typeof window ===
"undefined" which forces skipping all SSR GraphQL fetches for unauthenticated
users; confirm intent and, if SEO/public content must be server-rendered, change
the condition or introduce a separate flag so skipSsrFetch is false for public
pages during server rendering. Locate the getApollo call (getApollo(apolloState,
accessToken, ctx.locale, skipSsrFetch)) and ensure apollo is initialized with
server fetch enabled when the route/page is public (e.g., check route or a new
isPublicPage parameter) so apolloState and apollo.toJSON() contain SSR data for
crawlers while still skipping user-private queries for unauthenticated users.
🧹 Nitpick comments (2)
frontend/lib/with-apollo-client/get-apollo.ts (1)

268-270: Consider passing skipSsrFetch consistently for future-proofing.

Line 269 doesn't pass skipSsrFetch when reusing or creating the client on the browser, while line 270 does for server-side or changed-state scenarios. Although skipSsrFetch currently only affects server-side link selection and has no impact on browser clients, passing it consistently would improve maintainability and prevent potential issues if the browser path logic evolves.

♻️ Proposed consistency improvement
  const _apolloClient =
    !userChanged && !localeChanged && isBrowser
-     ? apolloClient ?? create(initialState, accessToken, locale)
+     ? apolloClient ?? create(initialState, accessToken, locale, skipSsrFetch)
      : create(undefined, accessToken, locale, skipSsrFetch)
frontend/lib/with-apollo-client/index.tsx (1)

107-107: Consider supporting skipSsrFetch for authenticated users for consistency.

The authenticated flow doesn't use or propagate skipSsrFetch, meaning authenticated users always perform full SSR data fetching. While this may be intentional (the optimization targets unauthenticated users), it creates an asymmetry in the API where the flag is only meaningful for one flow.

For consistency and flexibility, consider whether authenticated users should also have the option to skip SSR fetches in certain scenarios.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7a95a7 and f1a2fc1.

📒 Files selected for processing (2)
  • frontend/lib/with-apollo-client/get-apollo.ts
  • frontend/lib/with-apollo-client/index.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/lib/with-apollo-client/index.tsx (1)
frontend/lib/with-apollo-client/get-apollo.ts (1)
  • getApollo (255-298)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: CodeQL
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build-deploy
🔇 Additional comments (5)
frontend/lib/with-apollo-client/get-apollo.ts (3)

78-78: LGTM: Parameter addition is correct.

The skipSsrFetch parameter is properly typed and positioned.


226-228: LGTM: Server-side link selection is correct.

The conditional logic correctly uses skipSsrFetchLink when skipSsrFetch is true on the server, completely bypassing the normal link chain. This is the expected behavior for skipping SSR fetches.


210-215: This pattern is an intentional optimization, not a problem.

The skipSsrFetchLink is used only for unsigned users during server-side rendering to skip network calls. It returns null data so the page renders quickly. The client then receives an empty Apollo cache and uses real network links to fetch data after hydration. This is a standard SSR optimization pattern.

Apollo hooks natively handle null/loading states, and the client automatically fetches data when needed. No changes required.

frontend/lib/with-apollo-client/index.tsx (2)

18-18: LGTM: Props interface updated correctly.

The skipSsrFetch property is properly added as an optional boolean.


31-42: LGTM: Component correctly propagates skipSsrFetch.

The skipSsrFetch prop is properly destructured and passed to getApollo during client initialization.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @frontend/pages/index.tsx:
- Line 8: The home page is currently wrapped with withNoSsr which disables
server-side rendering and can hurt SEO/UX/perf; verify this is intentional and
if not, remove the withNoSsr wrapper around the page component (or only apply it
to the specific client-only subcomponents) and instead use the Apollo client
skipSsrFetch option from frontend/lib/with-apollo-client to skip problematic
queries during SSR; if you decide to keep withNoSsr, add a code comment
explaining why SSR is disabled for the page and document which component or
query required it (reference withNoSsr and skipSsrFetch in your change).

In @frontend/pages/study-modules/index.tsx:
- Line 3: The page currently wraps the Study Modules page with withNoSsr which
disables SSR entirely; instead change the implementation to keep SSR but skip
only the data fetch by using the skipSsrFetch mechanism: remove/stop using
withNoSsr on the default export (or component wrapper) and update the data
loading code (the fetch call or getServerSideProps/getStaticProps equivalent
used by pages/study-modules/index.tsx) to pass or check skipSsrFetch so the
component renders during SSR while deferring the expensive data fetch to the
client; reference the withNoSsr wrapper to remove and the skipSsrFetch
flag/function used by your data fetching logic to gate server-side fetching.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1a2fc1 and 0a73095.

📒 Files selected for processing (2)
  • frontend/pages/index.tsx
  • frontend/pages/study-modules/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build-deploy

@nygrenh nygrenh merged commit 1217a9d into master Jan 9, 2026
7 checks passed
@nygrenh nygrenh deleted the skip-requests branch January 9, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants