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

[⚠️ wip] Experimental Transport of Async Iterables #369

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alessbell
Copy link
Contributor

Experimenting with a multipart response in a server query containing @defer via PreloadQuery that can be consumed in a client component, triggering multiple re-renders as the chunks are transported over the server <> client boundary.

Copy link

netlify bot commented Oct 8, 2024

Deploy Preview for apollo-client-nextjs-docmodel ready!

Name Link
🔨 Latest commit c9b2911
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-nextjs-docmodel/deploys/67054234147cff0008b36a0f
😎 Deploy Preview https://deploy-preview-369--apollo-client-nextjs-docmodel.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Oct 8, 2024

size-limit report 📦

Path Size
{ ApolloNextAppProvider, ApolloClient, InMemoryCache } from '@apollo/experimental-nextjs-app-support' (Browser ESM) 4.81 KB (0%)
{ WrapApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client-react-streaming' (Browser ESM) 1.7 KB (0%)
{ buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport' (Browser ESM) 2.87 KB (0%)
@apollo/client-react-streaming (Browser ESM) 2.41 KB (0%)
@apollo/client-react-streaming (SSR ESM) 7.25 KB (0%)
@apollo/client-react-streaming (RSC ESM) 7.2 KB (+1.73% 🔺)
@apollo/client-react-streaming/manual-transport (Browser ESM) 3.08 KB (0%)
@apollo/client-react-streaming/manual-transport (SSR ESM) 8.2 KB (0%)
@apollo/experimental-nextjs-app-support (Browser ESM) 5.39 KB (0%)
@apollo/experimental-nextjs-app-support (SSR ESM) 10.58 KB (0%)
@apollo/experimental-nextjs-app-support (RSC ESM) 7.24 KB (+1.59% 🔺)
@apollo/experimental-nextjs-app-support/rsc (RSC ESM) 6.5 KB (+1.81% 🔺)

@phryneas
Copy link
Member

phryneas commented Oct 9, 2024

image

This should explain the race condition you're seeing:

At (1), a simulated query is started through client.onQueryStarted, and at (2) the first chunk is received, which calls client.onQueryProgress and then resolves the simulated query.

After that, at (3) useSuspenseQuery doesn't have the deferred fields in cache yet and thus starts a request which does not deduplicate as the simulated ongoing query has already resolved with the initial chunk.

The final chunk arrives later at (4) but without any special meaning attached to it.

We'll probably need some more sophisticated message-passing here so only "full data" or "final chunk" resolve the simulated query.

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