apollo-client-nextjs icon indicating copy to clipboard operation
apollo-client-nextjs copied to clipboard

RSC preloading mechanism

Open phryneas opened this issue 10 months ago • 6 comments

Resolves #212 and also prepares for #248 a bit.

Previews:

https://apollo-git-32cae2-apollo-client-next-package-integration-tests.vercel.app//rsc/dynamic/PreloadQuery/useSuspenseQuery https://apollo-git-32cae2-apollo-client-next-package-integration-tests.vercel.app//rsc/dynamic/PreloadQuery/queryRef-useReadQuery https://apollo-git-32cae2-apollo-client-next-package-integration-tests.vercel.app//rsc/dynamic/PreloadQuery/queryRef-refTest

On each you can call __APOLLO_CLIENT__[Symbol.for("apollo.suspenseCache")].queryRefs to investigate the queryRefs (if there are any)

phryneas avatar Mar 27 '24 14:03 phryneas

size-limit report 📦

Path Size
{ ApolloNextAppProvider, NextSSRApolloClient, NextSSRInMemoryCache } from '@apollo/experimental-nextjs-app-support/ssr' (Browser ESM) 7.88 KB (+1.2% 🔺)
{ WrapApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client-react-streaming' (Browser ESM) 1.5 KB (+7.48% 🔺)
{ buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport' (Browser ESM) 6.36 KB (+1.5% 🔺)
@apollo/client-react-streaming (Browser ESM) 2.23 KB (+4.91% 🔺)
@apollo/client-react-streaming (SSR ESM) 2.58 KB (+47.44% 🔺)
@apollo/client-react-streaming (RSC ESM) 1.65 KB (+20.62% 🔺)
@apollo/client-react-streaming/manual-transport (Browser ESM) 6.55 KB (+1.5% 🔺)
@apollo/client-react-streaming/manual-transport (SSR ESM) 7.14 KB (+12.55% 🔺)
@apollo/experimental-nextjs-app-support/ssr (Browser ESM) 8.49 KB (+1% 🔺)
@apollo/experimental-nextjs-app-support/ssr (SSR ESM) 9.12 KB (+9.49% 🔺)
@apollo/experimental-nextjs-app-support/ssr (RSC ESM) 867 B (0%)
@apollo/experimental-nextjs-app-support/rsc (RSC ESM) 626 B (0%)

github-actions[bot] avatar Mar 27 '24 15:03 github-actions[bot]

#194 Bundle Size — 1.03MiB (+2.47%).

74c2fd2(current) vs afa5bcc main#189(baseline)

[!WARNING] Bundle contains 1 duplicate package – View duplicate packages

Bundle metrics  Change 9 changes Regression 3 regressions Improvement 1 improvement
                 Current
#194
     Baseline
#189
Regression  Initial JS 898.87KiB(+0.82%) 891.55KiB
Regression  Initial CSS 70B(+100%) 0B
Change  Cache Invalidation 88.27% 0.04%
Change  Chunks 29(+20.83%) 24
Change  Assets 53(+17.78%) 45
Change  Modules 528(+3.13%) 512
Regression  Duplicate Modules 47(+56.67%) 30
Change  Duplicate Code 2.57%(+99.22%) 1.29%
Improvement  Packages 26(-10.34%) 29
No change  Duplicate Packages 1 1
Bundle size by type  Change 3 changes Regression 3 regressions
                 Current
#194
     Baseline
#189
Regression  JS 1.02MiB (+2.28%) 1MiB
Regression  Other 8.06KiB (+34.41%) 5.99KiB
Regression  CSS 70B (+100%) 0B

Bundle analysis report Branch pr/rsc-preload Project dashboard

relativeci[bot] avatar Mar 27 '24 15:03 relativeci[bot]

Quick thought: we need some warning if people add cookies or headers to context here as that could result in secrets to be dumped into the stream on accident.

phryneas avatar Apr 09 '24 09:04 phryneas

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
apollo-client-nextjs-experimental-nextjs-app-support ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2024 9:24am

vercel[bot] avatar Apr 09 '24 14:04 vercel[bot]

So here we have some previews:

https://apollo-git-32cae2-apollo-client-next-package-integration-tests.vercel.app//rsc/dynamic/PreloadQuery/useSuspenseQuery https://apollo-git-32cae2-apollo-client-next-package-integration-tests.vercel.app//rsc/dynamic/PreloadQuery/queryRef-useReadQuery https://apollo-git-32cae2-apollo-client-next-package-integration-tests.vercel.app//rsc/dynamic/PreloadQuery/queryRef-refTest

On each you can call __APOLLO_CLIENT__[Symbol.for("apollo.suspenseCache")].queryRefs to investigate the queryRefs (if there are any)

phryneas avatar Apr 15 '24 13:04 phryneas

Okay, tests in Vercel run fine now, and the error in latest is expected, since that AC release is still missing functionality we require.

I'll do another pass on everything here and then we should be ready for review 🎉

phryneas avatar Apr 17 '24 11:04 phryneas