-
Notifications
You must be signed in to change notification settings - Fork 42
Not sending data to the client. #325
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
Comments
I can prepare a reproduction if it would help. |
It works in your vite example because I see that |
I figured it out, the following works: import { WrapApolloProvider } from '@apollo/client-react-streaming'
import { buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport'
import { useStream } from 'react-streaming'
import { renderToString } from 'react-dom/server'
import React from 'react'
export const WrappedApolloProvider = WrapApolloProvider(
buildManualDataTransport({
useInsertHtml() {
const stream = useStream()
if (!stream) {
return () => {}
}
return async (callback: () => React.ReactNode) => {
const reactNode = await callback() // <--- added await
const injectionsString = renderToString(reactNode)
stream.injectToStream(injectionsString)
}
}
})
) |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Hmm... I believe what you have here doesn't work:
This delays the injection into the stream - but without blocking the stream, so React will already start to stream content that depends on the value that will only be injected later. You'd need to pause the stream, await, inject, and then resume normal stream functionality. PS: super cool to see more people playing with this! Please share your final result - maybe we can even add it as another integration test? |
Thanks for your answer, that makes sense. I'm currently working on fixing it (I'm very looking forward to Is there a rule of when it's allowed to inject to the stream? I've yet to read an official guide from React about this.
Apollo has quite a lot of goodies to make integration easy, it's quite neat. And, yes, we'd be up for an integration test! |
There's no official guidance on when it is safe to inject - our Generally: it seems that React might inject multiple chunks that belong together, but always does so synchronously. So waiting for the next |
That was my guess as well. (Funny coincidence.) Good to know that I ain't alone with my guess.
That looks quite neat CC @nitedani. |
FYI that's what |
Interesting! Tbh., I don't really want to overengineer that part. |
Me too, although I haven't heard any news about this nor injectToStream. |
Last I heard from the team they were trying to find more granular things than an I tried to hack together my "optimal" api by just editing React sources, and have multiple attempts, if you're interested in the exploration :)
|
I guess we can close this (I can't do it as I ain't OP), thank you @phryneas for your help! |
Good call - I believe the release of this was just announced at https://x.com/vike_js/status/1813474021201027129, so I'm going to close this here :) |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
I am trying to integrate this with
It's almost working, my code looks like this:
Issue: the data is not sent to the client. The output of the
console.log
above is the following:As you can see, the callback is called 4 times, but it produces only 2 script tags, with no data included.

The text was updated successfully, but these errors were encountered: