apollographql / apollographql/apollo-client-integrations

The build fails when fetchOptions.cache is set to "no-store" and query function is used in an RSC component.

Open
#391 1 comment 6 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
556
Forks
53
PR merge metrics
No merged PRs in 30d

Description

I encountered the "Dynamic server usage" error when `fetchOptions.cache` was set to `no-store` and the `query` function was used in an RSC component. According to the error message, it seems that Next failed to detect that the RSC component depends on API requests during prerendering.

```
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
ApolloError: Dynamic server usage: Route / couldn't be rendered statically because it used revalidate: 0 fetch https://swapi-graphql.netlify.app/.netlify/functions/index /.
See more info here: https://nextjs.org/docs/messages/dynamic-server-error
```

As a workaround, I could successfully build by defining `export const dynamic = 'force-dynamic';` in the Page component. However, Ideally, I would like to build without any workaround as it would be a more intuitive.

The errors occurred in both Next.js 14 and 15.

- Related: https://github.com/apollographql/apollo-client-nextjs/issues/339

### Reproduction
https://github.com/ktmouk/apollo-next-no-store

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproduction repository at https://github.com/ktmouk/apollo-next-no-store and run its build using fetchOptions.cache set to "no-store" with query in an RSC component. Compare the failure with the dynamic force-dynamic workaround and review related issue #339; done means the build succeeds without that workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js, typescript
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.