Hacker News new | ask | show | jobs
by otto_ortega 3162 days ago
I really love this approach, I have been thinking about it for some time now... However, as much as I like it, it seems that implementing a GraphQL server is not an easy task, and getting an in-depth understanding of how GraphQL works seems quite challenging.

I can devote a few days to read the JSON-API spec (http://jsonapi.org/) and get a pretty good understanding of it. I wish there were a way to consume JSON-API based APIs in the same declarative way GraphQL provides.

I'm thinking that a library that "translates" GraphQL queries to JSON-API requests will be a great solution.

4 comments

GraphQL is something that's relatively simple (and brilliant) but is one of those things that you just need to try properly first for it to click, especially if you have a background of implementing tons of REST based services.

The GraphQL related tools are top notch and implementing GraphQL server isn't any harder than a REST based server would be (one could even argue that it would be simpler). Even if you don't want to implement everything from scratch, tools like Postgraph[0] exists that pretty much automate it for you.

I made a simple tutorial[1] on wrapping an existing API with GraphQL here which goes through basics of settings up too.

[0] https://github.com/postgraphql/postgraphql [1] https://github.com/motleyagency/devday-tutorials/blob/master...

Thank you, I will be checking on Postgraph and your tutorial, I'm really interested in adding GraphQL to my development stack.
> it seems that implementing a GraphQL server is not an easy task

It's actually really easy, I encourage you to look into it! I've written plenty of APIs over the years and it's one of the more pleasant experiences I've had.

I wrote this simple 35-line GraphQL server implementing a demo schema in 2 minutes just while I was replying to your comment: https://gist.github.com/exogen/d5ddf86dd7f9efd15d3fabdace759...

You make it sound pretty easy, I will check on that example for sure.
You can wrap any existing API with graphql https://medium.com/taller-team/graphql-today-using-apollo-fo...
Regarding implementing GraphQL Servers: You can also check out https://github.com/graphcool/framework (I'm one of the creators) as well as the community driven https://www.howtographql.com/
The GraphQL Framework seems cool, specially the GraphQL CRUD API. However I don't like the idea of having to use GraphQL Schema Definition Language, I want something that takes my MySql or PostgreSQL Schema and automatically generates the code to allow me to perform CRUD operations over it via a GraphQL API, and extent from it...