-
Notifications
You must be signed in to change notification settings - Fork 47
Add initial Data preparing for SSR support #127
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
base: main
Are you sure you want to change the base?
Conversation
|
* Initial data for server-side rendering | ||
* Allows hydration from server-loaded data | ||
*/ | ||
initialData?: Array<T> |
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 have to think about this more but I don't think collections in general will want an initialData
option. TanStack Query is around conventions for you directly managing a client cache. TanStack DB aims to be a bit higher-level where these collection types take over managing the cache for you.
So in this world, the QueryCollection might have an initialData option but not necessarily other collections (e.g. Electric wouldn't).
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 think we'll probably just want an API which awaits running a query (i.e. all the collections are loaded and the query runs). So combination of TanStack/query#9135 & #129
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.
yes that makes sense for electric.
If there's an api which awaits running a query, would that just be a similar api to the the react query ssr hydration and rehydration?
https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr
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.
If there's an api which awaits running a query, would that just be a similar api to the the react query ssr hydration and rehydration?
Yeah exactly. Our general API goal is to copy TanStack Query directly whenever possible.
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.
looks like TanStack Query uses initial data as well. still remove initial data?
https://tanstack.com/query/latest/docs/framework/react/guides/ssr
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.
Yeah, we can add it back later if people ask.
The refactors are done if you'd like to pick things up again! |
Hey guys I had a stab at implementing initial data as a first step for SSR support. I can do hydration provider etc similar to tanstack query in a separate pull request.