-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
v3 - SSR - Queries render with loading: true even when data exists (Example repo provided) #6631
Comments
Not entirely sure if diff --git a/src/server.js b/src/server.js
index 34f6301..a8f9ab4 100644
--- a/src/server.js
+++ b/src/server.js
@@ -25,9 +25,7 @@ server
</ApolloProvider>
);
- getDataFromTree(app)
- .then(() => {
- const markup = renderToString(app);
+ getDataFromTree(app).then(markup => {
const initialState = apolloClient.extract();
if (context.url) { Thanks to your reproduction, I can confirm that this renders the following HTML, which seems correct/better? <!doctype html>
<html lang="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8" />
<title>Welcome to Razzle</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://localhost:3001/static/js/bundle.js" defer crossorigin></script>
</head>
<body>
<div id="root"><section><ul><li><div><span>1. </span><a href="http://nextjs.org">next</a></div></li><li><div><span>2. </span><a href="https://kesla">akhil</a></div></li><li><div><span>3. </span><a href="https://drgf">iuhg</a></div></li><li><div><span>4. </span><a href="https://with-apollo-subscription.now.sh/subscription">Hzz</a></div></li><li><div><span>5. </span><a href="http://google.com">Google</a></div></li><li><div><span>6. </span><a href="https://kevinrodriguez.io">TEST</a></div></li><li><div><span>7. </span><a href="https://band.us/ko">5555</a></div></li><li><div><span>8. </span><a href="https://band.us/ko">22</a></div></li><li><div><span>9. </span><a href="https://next-with-apollo.now.sh/">hiya gofod</a></div></li><li><div><span>10. </span><a href="http://seminor/">b、ん、m</a></div></li></ul></section></div>
<script>
window.__APOLLO_STATE__={"Post:ckcq6o3as0f2901558vrifyee":{"id":"ckcq6o3as0f2901558vrifyee","__typename":"Post","title":"next","votes":0,"url":"http://nextjs.org","createdAt":"2020-07-17T12:13:12.000Z"},"Post:ckcpx0huv0mzp0198uhppe5dq":{"id":"ckcpx0huv0mzp0198uhppe5dq","__typename":"Post","title":"akhil","votes":14,"url":"https://kesla","createdAt":"2020-07-17T07:42:54.000Z"},"Post:ckcpwzq4z0kio0130u2e42dy7":{"id":"ckcpwzq4z0kio0130u2e42dy7","__typename":"Post","title":"iuhg","votes":3,"url":"https://drgf","createdAt":"2020-07-17T07:42:18.000Z"},"Post:ckcpvx1xa0hb20145pd3rdmgg":{"id":"ckcpvx1xa0hb20145pd3rdmgg","__typename":"Post","title":"Hzz","votes":0,"url":"https://with-apollo-subscription.now.sh/subscription","createdAt":"2020-07-17T07:12:14.000Z"},"Post:ckcprlkbq0gnj01651r868ahx":{"id":"ckcprlkbq0gnj01651r868ahx","__typename":"Post","title":"Google","votes":10,"url":"http://google.com","createdAt":"2020-07-17T05:11:20.000Z"},"Post:ckcppcgx708pz0105k2f67bbl":{"id":"ckcppcgx708pz0105k2f67bbl","__typename":"Post","title":"TEST","votes":26,"url":"https://kevinrodriguez.io","createdAt":"2020-07-17T04:08:16.000Z"},"Post:ckcpo813504ov0154l2wlnkqg":{"id":"ckcpo813504ov0154l2wlnkqg","__typename":"Post","title":"5555","votes":6,"url":"https://band.us/ko","createdAt":"2020-07-17T03:36:49.000Z"},"Post:ckcpo7pr604o80154qtob8tqi":{"id":"ckcpo7pr604o80154qtob8tqi","__typename":"Post","title":"22","votes":4,"url":"https://band.us/ko","createdAt":"2020-07-17T03:36:35.000Z"},"Post:ckcpmz31m00hg0105mcazgdco":{"id":"ckcpmz31m00hg0105mcazgdco","__typename":"Post","title":"hiya gofod","votes":15,"url":"https://next-with-apollo.now.sh/","createdAt":"2020-07-17T03:01:52.000Z"},"Post:ckcplo0fs02yb010322i0alzf":{"id":"ckcplo0fs02yb010322i0alzf","__typename":"Post","title":"b、ん、m","votes":12,"url":"http://seminor/","createdAt":"2020-07-17T02:25:16.000Z"},"ROOT_QUERY":{"__typename":"Query","allPosts({\"first\":10,\"orderBy\":\"createdAt_DESC\",\"skip\":0})":[{"__ref":"Post:ckcq6o3as0f2901558vrifyee"},{"__ref":"Post:ckcpx0huv0mzp0198uhppe5dq"},{"__ref":"Post:ckcpwzq4z0kio0130u2e42dy7"},{"__ref":"Post:ckcpvx1xa0hb20145pd3rdmgg"},{"__ref":"Post:ckcprlkbq0gnj01651r868ahx"},{"__ref":"Post:ckcppcgx708pz0105k2f67bbl"},{"__ref":"Post:ckcpo813504ov0154l2wlnkqg"},{"__ref":"Post:ckcpo7pr604o80154qtob8tqi"},{"__ref":"Post:ckcpmz31m00hg0105mcazgdco"},{"__ref":"Post:ckcplo0fs02yb010322i0alzf"}],"_allPostsMeta":{"__typename":"_QueryMeta","count":18544}}};
</script>
</body>
</html> |
Thanks for the quick reply. Prior to my upgrade to v3 yesterday this worked on the latest v2 version as expected. Unfortunately due my usage of renderToNodeStream & emotion css steaming it means I can't use that returned string (it's also not mentioned in the documentation on v3 or v2.6) Is there now any purpose to the |
Can you share an example of the I'm interested in having an SSR function that supports streaming. The last time we investigated this, it seemed like Suspense might end up solving the problem, but I'm less convinced that's what people really want/need, these days.
Since the other two functions just call |
Sure, here is the same example but adding renderToNodeStream & emotion css streaming with some random styled boxes. https://github.com/bretthadley/apollo-issue-demo/tree/streaming |
There appear to be two related issues here, one server side and one client side. The server-side issue is But there's a second issue, which is client side. The first call to |
@jimrandomh Can you open a new issue for the second problem? No need for a long description. Feel free to copy/paste or link back to your comment here. |
Looks like maapteh beat me to it (#6651). I confirm that maapteh's issue is the same as the one I referred to. |
Hello everyone! Any updates on |
@AliTheAli In order to may SSR work again, may be just change the render logic like so
|
In my case, I was using axios as fetcher, changing to cross-fetch fixed the problem for me. |
I had a similar problem, which i tried to solve using #6631 (comment), but it did not work out for me. I then saw in the logs of my server that I had problem with the cache, not willing to automatically merge a field. Hope this can help other people having this issue |
I'm having the same issue, using Next.js, I noticed it happens if I use any
That doesn't happen if So my workaround was to simply put I'll try to include a repo with the scenario I'm describing as soon as possible. |
Intended outcome:
Using apollo getDataFromTree I expect the html produced by renderToString to not be in loading state.
Actual outcome:
The query loading is
true
even when data is populated. So the component will hit theHow to reproduce the issue:
Here is a repo. You can see on the server renderToString() the loading value is
true
even though data is populated with the query result. You can also seewindow.__APOLLO_STATE__
is correctly populated with the result.https://github.com/bretthadley/apollo-issue-demo
Versions
The text was updated successfully, but these errors were encountered: