Live data from Hacker News

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

pandastrike.com

91–100 of 166 posts

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

#91

Earlier quoted context omitted.

HTTP error codes are something of an embarrassment to the web. We have more codes for April Fools jokes than some of our most common situations we deal with. We have some bizarrely specific codes like Payment Required and Requested Range Not Satisfiable yet almost all real world application responses get dumped into 400, 500 and a few other codes. How about more specific and useful codes like: Parameter not Supplied,…

Agreed, the codes are a crap-shoot. We are working on a redesign of our API and I've pushed for always returning a 200 with a defined JSON structure of something along the lines of: { "status": true "data": { ... } } for success and { "status": false "errorCode": 123, "errorMessage": " ... " //Only shown in dev/debug mode } for failures. We haven't nailed it all down yet but there was no way I was going to do HTTP st…

This is what we do as well. As an added bonus, it makes writing client libraries for our API easier since error handling is more consistent. (Many HTTP libraries handle error status codes differently than 200s, which is annoying since you now have to handle errors in two places.)

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

#92
post #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…

I love when one engineer thinks he's smarter than ALL of the second largest Internet company's engineers put together--when he doesn't even have the context of working there to understand their reasoning. Clearly Facebook is evil and pays their employees solely to make us learn new technologies purely out of spite, not to improve their product better (which they get paid very well to do).

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

#93
post #45

I deal with REST zealots like this everyday :( just the fact that people spend so much time debating what is and what isn't REST should be a red flag that maybe it isn't the answer to everything. All the simple REST examples make it look like it is the perfect solution for CRUD tasks. But in reality API endpoints are not a straight pass through to the database. An endpoint may do any combination of CRUD tasks, it can…

HATEOAS-y design gives you a great deal of flexibility in how you structure your server side without that complexity bleeding into to the client.

E.g., by using full URLs throughout your API, your client doesn't need to care whether it's getting info from "http://example.org/item/23" or "https://cdn.example.com/aonteuh/d81c7d65-1352-48f0-97fd-dc1c...

Imagine if image tags in HTML were just "" and the browser knew to look them up at "http://example.org/images/23". You could make a functioning web site with that, but it would limit the things you could do, and maybe even the way you thought about linking.

That being said, there are almost always things you can do "better" by constructing the URLs in the client, like reducing response size, and fetching multiple items in a request. It's a trade-off, and I'd be wary of a 'REST enthusiast' who didn't acknowledge that. It could mean that they don't have enough real-world experience to have encountered the rough spots.

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

#94
post #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…

> This article is a load of bullshit.

Me and most people on the comments seem to agree, makes me wonder why is it on the top of the frontpage.

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

#95
post #49

Earlier quoted context omitted.

A query on a graph or a tree can both be RESTful. You can describe traversals of the graph or tree in a query embedded in an HTTP endpoint. You don't need to make repeated round trip queries to do the traversal unless you are unwilling to use a suitable query description. Metaphorically this is all pretty funny becuase the web is already a graph at a fundamental level.

The problem is that traversing a HATEOAS graph (like the www) requires a request at each edge. (The query is only the entry point to the graph, it doesn't help you traverse the graph. Relational joins make it so you don't need to traverse the graph, but this requires a lot of custom endpoints that bake in up-front knowledge about which nodes of the graph will need to be pre-fetched) edit: Either you edited or I misre…

Haha your edit is dead on. Your parent comment arguing for REST just reinvented GraphQL.

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

#96

Seems to me like the article and Relay are broken. 1) Why the new declarative query language for fetching attributes (columns) from objects (tables)? 2) Why build yet another transport mechanism on the top of HTTP, when there are so many to choose from already? 3) Oh, my god, boilerplate everywhere! What is this, Java?! /s Seriously, though, the OP has some serious issues with Facebook, but to be fair Relay stinks ba…

> Why the new declarative query language for fetching attributes (columns) from objects (tables)?

SQL isn't very composable- It was the right idea, but there's been a lot of progress in the last 50 years on how to traverse a database. It is all string-based, and it lacks a "pull syntax" (i.e. after the query completes, give me this graph-represented chunk of the result)

> Why build yet another transport mechanism on the top of HTTP, when there are so many to choose from already?

Relay is mostly agnostic on what mechanism is used to fetch results.

> Oh, my god, boilerplate everywhere! What is this, Java?! /s

Yeah, it's kind of awkward to do this stuff in Javascript- Look at what people are doing in more flexible languages, like here https://github.com/omcljs/om/wiki/Quick-Start-%28om.next%29

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

#97
post #45

I deal with REST zealots like this everyday :( just the fact that people spend so much time debating what is and what isn't REST should be a red flag that maybe it isn't the answer to everything. All the simple REST examples make it look like it is the perfect solution for CRUD tasks. But in reality API endpoints are not a straight pass through to the database. An endpoint may do any combination of CRUD tasks, it can…

> I deal with REST zealots like this everyday :( just the fact that people spend so much time debating what is and what isn't REST should be a red flag that maybe it isn't the answer to everything.

REST isn't the answer to everything, to be sure -- but its actually not the REST zealots who pretend it is. Rather, its the opposite: the people who pretend that REST is the answer to everything are the people who just throw around the label "REST" willy-nilly on whatever solution they've come up with to whatever problem they are dealing with.

REST zealots are generally fine with people offering solutions that aren't REST, especially for problems for which REST isn't a particularly ideal solution; what they object to is people claiming something is REST that isn't, which interferes with the ability of people to understand what REST is and what its good for, or to even understand what is being proposed.

> Overloading HTTP error codes is another interesting problem. If the server returns 404 for a resource, what actually happened?

A consumer really shouldn't, in the normal case, care what generated the error code, they should care what the error code means. 404 means the requested resource didn't exist. What component of the system processing the request made that decision shouldn't matter to the consumer (and may indeed change without any change to the meaning because of implementation changes.)

The people responsible for the implementation of the system returning the status code certainly care, and should have sufficient logging detail to support that.

In any case, HTTP/1.1 specifies [0] for 4xx series errors that "Except when responding to a HEAD request, the server SHOULD send a representation containing an explanation of the error situation, and whether it is a temporary or permanent condition." So, any implementation following the standard will, unless there is a good reason not to, provide an explanation of the error with the 404 response, so to the extent that there is further information that a consumer needs to understand, it should be provided.

> HATEOAS is just superfluous. I've met zealots who will defend it to the death. I just haven't found a practical use for it.

Have you used a web browser? If you have, and you understand how they work, you should be able to think of a practical use for HATEOAS. If its not applicable to your problem, that's fine to, just don't call whatever solution you cook up REST, because it isn't.

> REST encourages creating a CRUD interface for every single resource.

No, it doesn't.

> I've met people who have created literally 100 endpoints upfront for a small application - how is that maintainable?

Probably moreso than an application that puts 100 unrelated pieces of functionality into the same endpoint. Now, if there was too much functionality implemented for the problem, that's not REST's fault, which really addresses how you organize functionality, not what functionality you provide.

[0] http://tools.ietf.org/html/rfc7231#section-6.5

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

#98
This article is implying that a group of the best engineers of the world (Facebook and Netflix engineers came up with similar solutions with Relay and Falcor), are just dumb and don't know how the web works.

There are motivations behind those solutions, and are documented across videos, papers and documentation. It seems to me, that the author is ignoring the previous experience of such teams.

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

#99
post #38

Earlier quoted context omitted.

We could assume that, yes, everybody, Facebook included, just doesn't know REST (and implicitly assume that REST is an inherent good in the process). Or one could go "you know, Facebook has a lot of insanely smart people and their engineers are on record as having had problems with REST around stuff like complex object graphs and cycles, so maybe their solution is worth looking at." If you have to say "oh, this thing…

A large group of smart people often produce some really dumb ideas, like 'Google Wave' - so I wouldn't personally use 'Proof by Large Group of Smart People' in this case. Hacker News has been the home of many a bad idea by smart folk. Instead, maybe we should all be critiquing the points raised. In my limited experience, most engineers (yes including very smart ones) are more enamoured with their own ideas (and not d…

Right, but if your argument is that they just didn't understand REST, and yet they employ some of the smartest people around, so if they can't understand REST, what chance do the rest of us have?

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

#100
REST is one of the worst tech religions ever created yielding the most blinkered zealots. It's treated like a Bible where every word is taken as the Gospel truth that can't be tested, validated, compared or improved upon. Any alternative technology that reduces latency, improves performance and end user experience is considered an evil intrusion invalidating the purity of REST and must be vanquished.

In the name of REST, practitioners give themselves a free-ticket to develop large, over-architected, dumb chatty high-latency solutions at the expense of the end user as long as tech choices are made within their interpretation of REST. Normally technology serves the client, unless you're a REST zealot in which case what the needs of the client is secondary, its more important to obtain Internet kudos points by forcing your way up the maturity ladder.

No we must develop and shoe-horn all App and User experiences within the constraints of an ambiguous thesis that was built to link and update documents and create server-driven turn-by-turn apps. The fact they can't correctly interpret what different parts of REST means amongst themselves have generated programmer-decades worth of wasted discussions in the most useless bikeshed ever.

Post reply on HN