Live data from Hacker News

From REST to GraphQL

blog.jacobwgillespie.com

41–46 of 46 posts

Re: From REST to GraphQL

#41
post #2

This sounds like incompetent back-end design in the initial REST API. I never thought GraphQL would be more performant than REST-API + optimized queries. I don't have any experience with the current set of GraphQL libraries, but I've assumed that GraphQL is a solution to a completely different set of issues but with a possible performance penalty.

> This sounds like incompetent back-end design in the initial REST API. It doesn't even qualify as REST. They've got hard-coded URI hierarchies and IDs everywhere. That's the opposite of REST. REST APIs must be hypertext-driven: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hyperte...

I'm as cautious about GraphQL as one can get but I believe the greatest failure of REST is that it is unable to set clear rules and boundaries as to what is REST and what is NOT REST. I want to see a canonical implementation of what an ideal REST architecture is. Never saw one. GraphQL has clear spec which makes implementation easy. REST is at best a set of vague ideas and I understand why a lot of developers do not like that. because I don't.

Re: From REST to GraphQL

#42
post #7

I've heard some rumblings about adding GraphQL as a feature to Elixir / Phoenix. Anyone know more about this?

I am member of the Phoenix team. We are not adding GraphQL to Phoenix. What Chris McCord said in his keynote is that some of the ideas behind GraphQL/Falcor, like co-locating your query with your view, is also useful on the server side because it makes the code more maintainable (for example, you no longer need to write a big query in the controller with knowledge of all the view pieces). It also makes views easier t…

Would you please share a link to said keynote? I've been playing around with Elixir and plan on diving into Phoenix as well, so it sounds like it'd be interesting.

I've seen there's a library for creating GraphQL services with Phoenix, and I was also planning on using that as well.

Re: From REST to GraphQL

#43
post #10

Another possible solution while sticking to REST: instead of embedding all the sub-objects have an "expand" query param where you can list all the sub-objects/relationships you'd like returned (EG: GET /playlists/ID?expand=tags,tracks) This way you can still do everything in one request but not bloat the response data structure for situations that don't need the sub-objects.

this is how JSON-API works (Yehuda Katz, et al) http://jsonapi.org/

`GET /articles?include=author,likes&fields[articles]=title,body&fields[people]=name`

Re: From REST to GraphQL

#44

Earlier quoted context omitted.

I am member of the Phoenix team. We are not adding GraphQL to Phoenix. What Chris McCord said in his keynote is that some of the ideas behind GraphQL/Falcor, like co-locating your query with your view, is also useful on the server side because it makes the code more maintainable (for example, you no longer need to write a big query in the controller with knowledge of all the view pieces). It also makes views easier t…

Would you please share a link to said keynote? I've been playing around with Elixir and plan on diving into Phoenix as well, so it sounds like it'd be interesting. I've seen there's a library for creating GraphQL services with Phoenix, and I was also planning on using that as well.

Elixir conf 2015 videos are not yet on ConFreaks. Keep your eyes peeled.

Re: From REST to GraphQL

#45
post #41

Earlier quoted context omitted.

> This sounds like incompetent back-end design in the initial REST API. It doesn't even qualify as REST. They've got hard-coded URI hierarchies and IDs everywhere. That's the opposite of REST. REST APIs must be hypertext-driven: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hyperte...

I'm as cautious about GraphQL as one can get but I believe the greatest failure of REST is that it is unable to set clear rules and boundaries as to what is REST and what is NOT REST. I want to see a canonical implementation of what an ideal REST architecture is. Never saw one. GraphQL has clear spec which makes implementation easy. REST is at best a set of vague ideas and I understand why a lot of developers do not…

> I believe the greatest failure of REST is that it is unable to set clear rules and boundaries as to what is REST and what is NOT REST.

It hasn't failed in this. The principles are very unambiguous. The problem is that people don't actually read the source material and just follow crappy tutorials and ape other systems without understanding what REST is. Then they go on to build things that aren't REST, they go on to write crappy tutorials themselves, and everybody learning from them and aping their systems fail just as badly. The problem is not clarity of communication, it's bad PR.

> I want to see a canonical implementation of what an ideal REST architecture is. Never saw one.

You're using a pretty good example right now. The World-Wide Web is an implementation of the REST architecture. It's not perfect, but it's the archetype REST was born from.

> REST is at best a set of vague ideas and I understand why a lot of developers do not like that. because I don't.

Look, it's really not difficult to find the concrete, unambiguous description of REST. It's right here:

http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch...

All you had to do was Google it or look at the Wikipedia page. There is nothing vague about it whatsoever. The problem is not that REST is vague, the problem is people just don't bother reading the source material.

Re: From REST to GraphQL

#46

Earlier quoted context omitted.

Would you please share a link to said keynote? I've been playing around with Elixir and plan on diving into Phoenix as well, so it sounds like it'd be interesting. I've seen there's a library for creating GraphQL services with Phoenix, and I was also planning on using that as well.

Elixir conf 2015 videos are not yet on ConFreaks. Keep your eyes peeled.

The mentioned talk "What's Next for Phoenix" by Chris McCord is now online https://youtu.be/-7Q3bD4qSVE?list=PLE7tQUdRKcyZb7L66A9JvYWu_...
Post reply on HN