-
-
Notifications
You must be signed in to change notification settings - Fork 703
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
exploration for Apollo Client integration #2698
base: main
Are you sure you want to change the base?
Conversation
packages/start/src/client/Meta.tsx
Outdated
streamedValues: new Proxy( | ||
{}, | ||
{ | ||
set(t, key, v) { | ||
const res = Reflect.set(t, key, v) | ||
window.__TSR__ROUTER__ && | ||
__TSR__ROUTER__.emit({ type: 'onStreamedValue', key }) | ||
return res | ||
}, | ||
}, | ||
), |
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.
Streamed values arriving now emits a router event.
|
||
const handledEvents = new WeakSet<object>() | ||
|
||
export const ApolloProvider = WrapApolloProvider((props) => { |
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 file is essentially all that's needed for Apollo Client streaming SSR integration with fetch-as-you-render (useSuspenseQuery
etc).
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 would end up in it's own package, I guess?
// @ts-ignore unavoidable due to the ternary in arguments | ||
router.options.context.preloadQuery = | ||
createTransportedQueryPreloader(apolloClient) | ||
router.options.transformer = defaultTransformer.withTransformers([ |
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'm gonna be honest, I would prefer to have a router.options.transformers
option - that way we could merge user-supplied transformers with "library-supplied" ones, which is currently not possible.
I made a 15 minute video explaining some of the thoughts behind this, so that might be a starting point :)
https://www.youtube.com/watch?v=G-8Q_o2eKhg
This just copies over another example page so you can kinda ignore the first commit when looking at the diff.