-
Notifications
You must be signed in to change notification settings - Fork 43
Adds support for useBackgroundQuery and useReadQuery in Streaming SSR
#38
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
Conversation
when calling `useBackgroundQuery`
…xt to ensure identity in `QueryManager.inFlightLinkObservables`
| @@ -1,5 +0,0 @@ | |||
| import { PollSkeleton } from "@/components/poll"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add this back - I temporarily removed it for testing with useBackgroundQuery where using a Suspense boundary directly was preferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder to add this back :)
phryneas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already some feedback. I'm curious why that deduplication change didn't do what we expected, though. Gonna look a little deeper 👀
|
@alessbell I found out what was going wrong. For type safety, we need a Add that and you'll immediately notice ;) |
call cache.write after resolve to avoid scenario where promise resolves without a query subscribing to the promise
- Refactor `uninitialized` boolean, merge arrays instead.
phryneas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good!
Only some minor little changes, then this should be good to go!
This PR creates a new class,
NextSSRApolloClientinpackage/src/ssr/NextSSRApolloClient.tsx, which can be imported and used in client components where one would useApolloClientoutside of the app directory.This extension of the
ApolloClientclass registers "background queries" (queries triggered by components rendering on the server) via the sameregisterLateInitializingQueuestrategy already used to register results on the client. By keeping track of queries already run on the server, we can avoid duplicating these requests on the client when the same components are executed in the browser, since the result will be streamed in once it has completed.