Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't prevent client from making requests during Server-Side Render #7940

Open
zenflow opened this issue Apr 1, 2021 · 1 comment
Open

Comments

@zenflow
Copy link

zenflow commented Apr 1, 2021

Intended outcome:

I have a Next.js/AC app which uses the ssrMode: true option, and require("@apollo/client/react/ssr").getMarkupFromTree to preload data for some pages. That works fine, but for the other pages, I don't want to preload data. For these pages I want to allow some "loading" states server-side so that it can be prerendered & served statically in production.

By just not using getMarkupFromTree on these pages, the page doesn't have blocking data requirements (can be prerendered) and renders with the desired loading state, but when the page is rendered, the queries are still executed over the network.

I would expect there to be a way to prevent these useless requests in this very common scenario.

Actual outcome:

There doesn't seem to be any way to prevent these requests.

client.disableNetworkFetches = true doesn't actually disable network fetches. It forces the fetch policy to "cache-first" (which does use network fetches when data is not available in cache, so the name "disableNetworkFetches" seems misleading). This is enabled automatically by using ssrMode: true in apollo client options anyways.

Versions

@apollo/client v3.3.13

@zenflow
Copy link
Author

zenflow commented Apr 1, 2021

My current workaround is to substitute my actual apollo link with ApolloLink.empty() when creating the apollo client for these non-ssr pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants