-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Provide hooks for server-side rendering #136
Comments
I'm not sure if this is the right place to report this, but the I believe this can be fixed by switching https://github.com/facebook/fbjs/blob/cb1f3026bcc3852616fad85b8aa12dca554fb093/src/__forks__/fetch.js#L14-L15 to use |
@taion is right, when I try to use server rendering, I get this error:
which is what you get when you use Is there any workaround? |
I just tried to locally change my node modules and to replace (inside require('whatwg-fetch');
module.exports = self.fetch.bind(self); by: module.exports = require('isomorphic-fetch'); and my app seems to "isomorphically" work fine, so that was the only thing preventing me from rendering relay components on server side. I guess Is this going to be addressed soon? Thanks! |
Yeah, this same issue affects using Relay on React Native @yungsters @zpao - should we require that users bring their own |
I don't think splitting out The nice thing about using |
I had looked at node fetch modules when @steveluscher did this initially. We sort of brushed off the node case. But it's obviously an issue people are having. I hadn't seen For React Native… I'm not sure. The node one uses node APIs and maybe we bring in some shimming so that packaging works but I also wouldn't be surprised if we don't. Would want to talk to experts. There might already be a Seems like we can probably move the fetch discussion elsewhere since it's not really the point of this issue, just a piece of the puzzle. |
I was trying server rendering with Relay, using all hints which were provided in github answers:
And after that I have issue with two versions of React, which I can not resolve, because I delete react node_module everywhere where it was used, and still have this error. So, does somebody has an example of simple server rendering with Relay and GraphQL? Or, does somebody has success in server rendering with Relay + GraphQL. Thank you. |
Actually fetching data with Relay + GraphQL is working, the problem in render Relay components. |
@mikhail-riabokon it won't work until facebook/fbjs#61 is merged |
@adriantoine Yes. I know it, but fetch is not only one problem with Relay on server. |
My repo example includes node_modules where I changed this packages, just for test. |
Change some formatting around the ref facebook/relay#136.
👍 Do we have any updates on this? Spent the past 2 days trying to figure out how to use Relay Isomorphically... |
This is slowing my team up. I would love to see a solution. From what I can tell the issue is with react-native: facebook/fbjs#60 |
We've sort of derailed this issue I think. Ultimately those |
I don't believe anybody is actively working on this internally right now (although this issue is currently assigned to @voideanvalue he's working on other stuff presently). It's possible that providing support to an external contributor who wants to work on this might get us there faster than doing it ourselves. |
@wincent I'm more than willing to give a hand.. can you or @voideanvalue give me a starting point or two where I could start spelunking into the problem? |
Any update on this? |
Glad to report that I have just managed to implement server side rendering for Relay: https://github.com/denvned/isomorphic-relay Here is an example: https://github.com/denvned/isomorphic-relay/tree/master/examples/star-wars @voideanvalue, can you please have a look? And thank you for the great info. It helped me very much! |
👍 |
Any word on this? Anyone on the Relay team working on this at all yet? |
I'm wondering the same. Most other third party implementations get the job done, but fall under certain scenarios. |
With the help of the community we've made good progress towards this. The main prerequisite is making all Relay state contextual instead of global, so that the same node process can be used to handle HTTP requests from multiple users. Almost all modules have been converted and there are pending PRs for the remaining pieces. We're tracking that work in #558. |
Thanks @josephsavona, exciting to see so much progress on this. I'll keep an eye on #558 👍 |
Hello, what is the current state of this issue? I'm currently doing research on how to integrate relay into our react infrastructure and was wondering if ss-rendering is now easily possible? |
#558 is closed. That means it should work now? |
@andyhu server rendering does work today, check out https://github.com/denvned/isomorphic-relay |
@josephsavona do you guys think that |
I haven't used it personally (yet), but from my external perspective it looks pretty good. |
Up! |
Any news on that? |
@DenisIzmaylov @rdewolff Our current recommendation is to use |
This looks closeable to me now, so going to close it. |
Are there any plans to eventually bring that support into the main Relay repo, or will it remain a third-party thing for the time being? |
No immediate plans. We very much like the idea of having a small, well-defined core, upon which and with which other stuff can be straightforwardly built. (Note: this is more aspirational than reality at the moment, but we are working on it.) |
Is there a recommendation for server-side rendering with Relay Modern? Should we wait for an update to |
@tomconroy I'd like to know this also. This looks useful: |
@chadfurman |
This was so helpful, thank you so much!
…___________
chads.website
LinkedIn <https://linkedin.com/in/chadfurman>
Github <https://github.com/chadfurman>
Twitter <https://twitter.com/chadfurman>
___________
On Tue, Aug 8, 2017 at 1:26 PM, Tom Conroy ***@***.***> wrote:
@chadfurman <https://github.com/chadfurman>
That article seems to ignore an important step – rehydrating the relay
store – which without will cause apps to flash to "loading" while the
client-side query loads. I would suggest taking a look at @taion
<https://github.com/taion>'s work in found-relay (the solution afaik is
still "naive")
relay-tools/found-relay#16 (comment)
<relay-tools/found-relay#16 (comment)>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#136 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAmxIqC25-t39o1q03jXHb2iLIFojtg6ks5sWJo9gaJpZM4FwDq1>
.
|
Relay was built to support server-side rendering, and we are doing so internally at Facebook. @voideanvalue gives a great overview of how that works. However, the necessary hooks and APIs are not exposed in the OSS release. A future update to Relay will provide support and documentation for this feature.
The text was updated successfully, but these errors were encountered: