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

Routing docs #1628

Closed
taion opened this issue Apr 18, 2017 · 4 comments
Closed

Routing docs #1628

taion opened this issue Apr 18, 2017 · 4 comments

Comments

@taion
Copy link
Contributor

taion commented Apr 18, 2017

Wanted to add some quick notes on routing docs –

  • I don't think the Relay.Route mechanism was ever generally used by external users of Relay
  • We're currently using a different router called Found that uses environment.primeCache to preload data for nested routes, to simulate the effect of nesting <Relay.Renderer>s while still fetching all the data in parallel
  • The most significant downside to using React Router v4 is that there isn't a good way to resolve parallel data dependencies, e.g. if your parent and child routes had separate Relay data dependencies, and you just nested <QueryRenderer>s, you'd end up unavoidably waterfalling for no good reason
    • With React Router v2 and v3 this was somewhat possible with react-router-relay, but I may not upgrade that package to work with Relay Modern
@stubailo
Copy link

If you were using React Router, couldn't you statically compose the fragments and load all of the data, even though the components haven't been displayed yet?

@taion
Copy link
Contributor Author

taion commented Apr 19, 2017

With v2 and v3, yes, and that's exactly what I do in react-router-relay.

The v4 API doesn't meaningfully support this use case since it's components all the way down, and the config-driven support is highly suboptimal.

I take a slightly different approach in Found with Relay 1 – I call into the imperative Relay APIs directly and then render a <Relay.ReadyStateRenderer> on each level. This is a bit more flexible (e.g. we can skip the cache on a route-by-route basis). I think with some care around the GC, I can use this same approach with Relay 2... maybe.

@taion
Copy link
Contributor Author

taion commented Jun 3, 2017

I've updated Found Relay to support Relay Modern on an alpha release: https://github.com/4Catalyzer/found-relay/releases/tag/v0.3.0-alpha.1.

The API is very similar in principle to the old react-router-relay API, but matches <QueryRenderer> instead of <Relay.Renderer>. It continues to dispatch all queries for routes in parallel (and in parallel with fetching async components).

Does this make sense as an option here? I have an implementation TodoMVC with routing and Relay Modern here for reference. The mutations are a bit complicated than in the non-routing example due to the filtered views, and more complex than the Relay Classic example because they are more correct with avoiding unnecessary refetching.

@kassens
Copy link
Member

kassens commented Jun 3, 2017

Please feel free to send a PR to include found-relay and I guess remove Relay.Route. I'm happy to seem more options highlighted, especially ones that work for people in the OSS community given we're no longer trying to tie Relay to any specific routing idea (so happy about this, focusing on the problem of data management is already plenty or work)

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

3 participants