Skip to content
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

Help Wanted :Example with server side Rendering with v 0.8.0 #1058

Closed
AhmadEl-Banna opened this issue Apr 18, 2016 · 13 comments
Closed

Help Wanted :Example with server side Rendering with v 0.8.0 #1058

AhmadEl-Banna opened this issue Apr 18, 2016 · 13 comments

Comments

@AhmadEl-Banna
Copy link

I really need an example with server side Rendering with v 0.8.0.
Thank you

@wincent
Copy link
Contributor

wincent commented Apr 19, 2016

Thanks for the question @AhmadEl-Banna. Your best bet is likely going to be to use isomorphic-relay.

I see you already commented on the relevant issue there, so I'm going to close this one out.

@wincent wincent closed this as completed Apr 19, 2016
@AhmadEl-Banna
Copy link
Author

@wincent I just want to have another implementation, and also the documentation for the v 0.8.0 is not published yet , so an example will be the only thing we have other than the release Note.

@wincent
Copy link
Contributor

wincent commented Apr 20, 2016

The latest version of the docs were published to the website when v0.8.0 went out. Note that there are some new APIs that we have intentionally left undocumented, as we are still iterating on them and we want to avoid churn. Other than those things specifically called out in the changelog, is there anything specific you were expecting to be published in the docs with v0.8.0?

We want Relay to work in a server-rendered context, but Relay itself is unlikely to provide end-to-end integration or examples for this, at least in the foreseeable (short-term) future. This is something we see largely being implemented in "user space", outside the core framework, which is why we refer people to projects like isomorphic-relay.

@edvinerikson
Copy link
Contributor

edvinerikson commented Apr 20, 2016

I have created a PR (denvned/isomorphic-relay#33) on the isomorphic-relay repo however I can't get the client fetching working.. I am prompted with RelayQueryWriter: Could not find a type name for record RmFjdGlvbjoy. when I try to fetch from the server (server data works fine).
The error is caused because the __typename field is not queried and I can probably solve it by adding it manually.. but I think Relay should add that field for me when it needs it. @wincent Do you have any suggestions?

@wincent
Copy link
Contributor

wincent commented Apr 20, 2016

Great work on that PR. Adding __typename explicitly sounds like a good work around for now. In general, Relay tries to add __typename automatically whenever it can't infer the concrete type of a node, so perhaps you have found an edge case. Can you try the manual workaround and if it works let us know?

@edvinerikson
Copy link
Contributor

Thanks @wincent!
It works fine when I add the __typename field into the query. Can you point me to the code where it checks whenever it needs the __typename field?

Another question: Relay is splitting my query into multiple requests instead of batching them into one when I use arguments on the route. Is this desired behaviour?
https://github.com/edvinerikson/isomorphic-relay/blob/relay-08-support/examples/star-wars/src/routes/StarWarsAppHomeRoute.js#L17

@nodkz
Copy link
Contributor

nodkz commented Apr 21, 2016

@edvinerikson this is task of RelayNetworkLayer to combine multiple queries.
Firstly I try to combine queries into one in my own NetworkLayer, but it is to hacky to merge RelayQueryRoots, there can be same variables names in different queries.

And Joseph advised another solution #520 (comment)

So I implement it in https://gist.github.com/nodkz/d9a6380d55067192295382e8e490f39f
Also I was forced to write wrapper for express-graphql middleware. You can found it by the link above.

@edvinerikson
Copy link
Contributor

Thanks for the info @nodkz, but do you think this still apply when you only have one query?
To be more clear, I only have one root query that gets splitted into two network requests.
e.g factions(names: ["rebels", "empire"]) creates two network requests, one for each name (rebels and empire)

@nodkz
Copy link
Contributor

nodkz commented Apr 21, 2016

Hm. First time see such behaviour. And with your case I think is strange. I understood why relay split queries by router, but here I have no thoughts.

@edvinerikson
Copy link
Contributor

Yeah same for me, I started seeing this in Relay 0.8 both in the Star wars app and a project I am currently working on.

@nodkz
Copy link
Contributor

nodkz commented Apr 21, 2016

Oh, I try update tomorrow on 0.8 and confirm will I have similar query splitting.

@nodkz
Copy link
Contributor

nodkz commented Apr 22, 2016

@edvinerikson spent all current day for this writing RelayNetworkLayer with middlewares https://github.com/nodkz/react-relay-network-layer
So my updating to 0.8 will be at next week.

@josephsavona
Copy link
Contributor

factions(names: ["rebels", "empire"]) creates two network requests, one for each name

@edvinerikson For legacy reasons, Relay splits "plural" root queries into individual queries. In general we want to diff each root value separately, since different fields may be missing for different root values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants