Live data from Hacker News

Facebook Relay: An Evil And/Or Incompetent Attack on REST

pandastrike.com

11–20 of 166 posts

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#12
I have a near-immediate distrust of anyone who says "you're all doing REST wrong." I've built my share of REST APIs. I've seen firsthand the tradeoff they face as more use cases are added, between letting the payload size keep creep upwards or exploding the number of endpoints. I like what GraphQL is doing to fix that.

On the other hand I've never seen an API in the wild that I felt would really satisfy a REST purist. In theory, it'd be great to be able to stick a dumb HTTP cache in front of your app and have that solve all your performance and scalability problems. In practice, you have to sacrifice too much.

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#13
Here's a quote which I think well describes Facebook's stance on REST, before GraphQL and Relay were public. This is the idea that motivated GraphQL and Relay.

"REST does a shitty job of efficiently expressing relational data. ... I mean REST has its place. For example, it has very predictable performance and well-known cache characteristics. The problem is when you want to fetch data in repeated rounds, or when you want to fetch data that isn't expressed well as a hierarchy (think a graph with cycles -- not uncommon). That's where it breaks down. I think you can get pretty far with batched REST, but I'd like to see some way to query graphs in an easier way."

-- Pete Hunt in 2013, when he worked at Facebook on React: https://news.ycombinator.com/item?id=7600565

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#14
post #3

I have a problem taking seriously any article that spreads FUD by accusing their targets of spreading FUD. The people who build React and the related ecosystem are incredibly smart people trying to make the web better. I'm certain there's no ill-intent in their motives. Regardless, they open source pretty aggressively. If an open technology from Facebook displaces another open technology from another source, I don't…

Couldn't have said it better myself. I'm sure there are some great points in this post but I can't get over the obviously biased perspective (and borderline ad hominem attacks on FB).

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#16
This article is a load of bullshit. When Facebook announced Relay it made immediate sense to me. The problem of fetching the right data from the backend is a pain in the ass for anyone that has built more than a simple todo app.

To me it is like sending a SQL query to the backend and instead of getting rows back you get objects nested in a way you specify.

The problem when using REST "correctly" is that the way your objects interrelate is not necessarily the same way on the backend as it is on the UI. So you end up creating custom REST endpoints for complicated UI that does not map directly to how your objects are related in the database.

This article has no substance in how they want to solve it besides just spouting "use REST correctly".

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#18
post #2

fwiw, pandastrike seems to be on a crusade against all things Facebook/React so take this with a grain of salt. https://twitter.com/vjeux/status/655128064754499588

It's all in the game: https://gettingreal.37signals.com/ch02_Have_an_Enemy.php

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#19
post #5

> a REST endpoint can return whatever you want. If you only want a subset of that graph, make an endpoint around that subset. So we have to make endpoints around every possible subset? > You want to avoid large object graphs anyway, for two reasons. Returning coarse-gained chunks of data tends to work against effective caching strategies, whether you're using REST, Relay, or anything else. You have to cache the whole…

"So we have to make endpoints around every possible subset?" No, you use the query in querystring. One way or another you're offering a query interface. A lot of REST is just about how you offer the same interfaces you were planning on offering anyhow. Which is probably a source of a lot of the frustration REST advocates experience. If you're genuinely doing something that REST can't do very well, OK then, but if you…

> No, you use the query in querystring.

Ok, but doing that straight on top of HTTP, will only cache queries that are exactly equal to previous ones. Not queries that are a subset of previous queries.

Re: Facebook Relay: An Evil And/Or Incompetent Attack on REST

#20

> a REST endpoint can return whatever you want. If you only want a subset of that graph, make an endpoint around that subset. So we have to make endpoints around every possible subset? > You want to avoid large object graphs anyway, for two reasons. Returning coarse-gained chunks of data tends to work against effective caching strategies, whether you're using REST, Relay, or anything else. You have to cache the whole…

s/catch/cache/ ?

Thank you.
Post reply on HN