The Ultimate GraphQL Solution, Part 2

Cameron Ellis
2 min readJan 18, 2017

--

Recently, I wrote an article about “The Ultimate GraphQL solution”, and published it, without really posting it anywhere. Since it has received some replies, I’ve decided to continue writing about my travails with graphql, and how I’m coming to grips with what I hope to achieve with graphql.

A better definition

First, the title was a misnomer, as there’s really no “Ultimate” graphql solution. Secondly, I didn’t really specify that it had to be written in Javascript. Well, now I’m going to narrow the focus a bit. What I wanted originally was what I’ll simply be calling a “graphql ORM”. I know that doesn’t make sense, but you know what I mean. An SQL orm maps tables to classes. A Graphql ORM simply maps tables, or mongodb/nosql schema, to graphql schema. So, what I’ve been seeking is a GraphQL orm for javascript.

Latest developments

So far, I haven’t really done much on this project, which I’m calling Mastodon, besides — loosely — defining the what of the project, and then going searching in my extremely limited free time for the how.

GraphQL Compose

One library I’ve come across, purely by chance ( actually not by chance, I happened to be reading issues in graffiti-mongoose ) is graphql-compose. Now, I know the GraphQL js community is small right now and still deciding on what to standardize on — most github stars seems to go to postgraphql — but I’m really not sure why graphql-compose hasn’t gotten more attention. It seems to support almost everything I’ve outlined in my original post. It doesn’t yet support postgres natively, but, reading through the issues, it does support custom queries! See here: https://github.com/nodkz/graphql-compose/issues/32. So I reached out to nodkz, and I think i’m going to take a stab at standing on the shoulders of giants/DRY instead of writing everything from scratch.

To be fair to graffiti, the risingstack team also has plans for all of this stuff, it’s just that nodkz’s feels a bit more polished ( though far less people seem to have battle tested it, fwiw ).

Speaking with nodkz, it seems like the best way forward would be to write a plugin ( using knex or maybe the graphql-knex-resolver ) on top of graphql-compose. Perhaps mastodon will continue on, but I’m going to look into this path first.

--

--