-
Notifications
You must be signed in to change notification settings - Fork 36
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
Adds support for useBackgroundQuery
and useReadQuery
in Streaming SSR
#38
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 :)
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.
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,
NextSSRApolloClient
inpackage/src/ssr/NextSSRApolloClient.tsx
, which can be imported and used in client components where one would useApolloClient
outside of the app directory.This extension of the
ApolloClient
class registers "background queries" (queries triggered by components rendering on the server) via the sameregisterLateInitializingQueue
strategy 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.