question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve clarity of backend route composition

See original GitHub issue

Is your feature request related to a problem? Please describe. If I start out a page with the following markup:

<Get path="/people">
  {data => (
    <Get path="/products" />
  )}
</Get>

I find it unintuitive that the resulting backend path in the child Get component is ${base}/people/products, which, in an HTML analogy, would make more sense if I omitted the slash like in <Get path="products">. It feels like an overhead to have to do ../products in order to replicate the ‘absolute path’ behavior, or to pull in the backend URL again to set as base prop. I wonder if we can make this more predictable.

Describe the solution you’d like The following code:

<Get path="/people">
  {data => (
    <Get path="/products" />
  )}
</Get>

should make requests to ${base}/people and ${base}/products, whereas

<Get path="/people">
  {data => (
    <Get path="products" />
  )}
</Get>

should make requests to ${base}/people and ${base}/people/products.

In this proposal, URL composition can be disabled by simply adding a slash. As a personal preference, I can even see myself forcing absolute paths at all times in order to remove coupling my components to the entire component hierarchy (and thereby making rearranging components risky). We could even enforce this as a kind of strict mode, or issue runtime warnings if the user opts into them.

Alternatives I can foresee some confusion happening when relative and absolute positions are nested, but I’m sure we can figure out a nice set of rules on the implementation level. Maybe we can gather some data from projects using restful-react - how much nesting/composition is desired and how nesting complexity is managed - to see what API makes the most sense.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
peterszerzocommented, Oct 2, 2018

Hi @elangobharathi - sure, feel free to give it a go. It’ll be helpful to look at https://github.com/contiamo/restful-react/pull/33 to see all the things we’ve tried and discussed so far.

2reactions
TejasQcommented, Oct 1, 2018

If @peterszerzo says so, absolutely. Welcome to the community. 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Boost Performance With Lazy Loading - Codemotion
This guide, developed with Be Digitech Solutions, analyzes how the “lazy loading” design pattern/technique is a game-changer for improving user ...
Read more >
Micro Frontend Architecture and Best Practices - XenonStack
Micro Frontend Architecture's Benefits and its Best Practices to scale Frontend and to build a powerful and feature-rich web application.
Read more >
How To Bootstrap A Quality Golang Backend - 8th Light
This function allows you to use composition and build all of the routes in your app, or just build the users' routes when...
Read more >
Micro Frontends - Martin Fowler
In this article we'll describe a recent trend of breaking up frontend monoliths into many smaller, more manageable pieces, and how this ...
Read more >
Introduction to Apollo Federation - Apollo GraphQL Docs
It receives incoming GraphQL operations and intelligently routes them across your ... To create a supergraph schema, you use a process called composition....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found