
Show HN: Generating GraphQL servers for Go - vektah
https://github.com/vektah/gqlgen
======
013a
I feel that, in typed languages, the only GraphQL oriented code you should be
writing is the schemas and the resolvers. Manually implementing the models in
your language's type system seems unnecessary and is a recipe for mistakes and
drift between the schemas and those types.

~~~
a-saleh
I think I would rather write types and derive schemas. Not sure if it were
possible to derive resolvers?

~~~
013a
There's a good argument that GraphQL can become the single SDL you use to
define the API of many services written in many different languages. In this
sense, it makes sense to write GraphQL and generate the language constructs;
kind of an "outside->in" approach. If you're codegening your API from language
constructs, the API will inevitably begin to use patterns that make sense in
your language, not patterns that are universal to GraphQL or your entire
system.

That being said, I don't agree with it. I'm not a fan of GraphQL for inter-
service communication; it makes sense at the internet API boundary, but once
you're inside your service mesh I prefer something simpler and easier to test,
like gRPC.

------
faizshah
Not to derail the discussion, but I just got started using GraphQL myself.
I've been using Apollo and just started looking at Graphcool. I was wondering
if anyone knows of an offline first solution for GraphQL on mobile (ios and
android, native or nativescript compatible)?

I was hoping to use Apollo on all platforms but it seems I would need to use a
custom solution for mobile while on web there's some choices (for offline
first): [https://github.com/apollographql/apollo-cache-
asyncstorage/i...](https://github.com/apollographql/apollo-cache-
asyncstorage/issues/6)

Currently I'm planning to go with couchdb/couchbase-lite for mobile but I
would prefer a graphql solution. I'm also investigating AWS AppSync which
appears to have offline support, but I haven't read that deeply into it yet:
[https://aws.amazon.com/appsync/](https://aws.amazon.com/appsync/)

~~~
realPubkey
Hi faizshah. I created RxDB (
[https://github.com/pubkey/rxdb](https://github.com/pubkey/rxdb) ), an
offline-first-database (javascript) which works for your requirements, but
only with the couchdb-stack.

I did many attempts to create a graphQL-plugin which streams graphql-data into
an the offline-first store. But this is not completely solvable because of the
lacking graphQL-streaming-capabilities. The thing is, when the users goes
offline for an hour an then online again, there is no way to get the changes
of the last hour out of graphQL which means the user then would either have
missing updates or has to redownload the full state again. The current
streaming-api of graphQL requires a stable connection and is so not useable
for offline-first.

~~~
faizshah
Thanks for the info and the reply, this seems like a great solution for me for
nativescript and I like the docs and feature set. But it's a little
heavyweight for web, is there a lite version or a way to create a custom
build?

~~~
realPubkey
Yes there is an option to do custom builds.
[https://pubkey.github.io/rxdb/custom-
build.html](https://pubkey.github.io/rxdb/custom-build.html)

------
sorenbs
This is super cool. It looks very similar to graphql-binding
[https://github.com/graphql-binding/graphql-
binding](https://github.com/graphql-binding/graphql-binding)

GraphQL Bindings are generated from a GraphQL schema and provides static
typing in various languages. Right now code-gen for typescript is supported.
Scroll down a bit on
[https://www.prismagraphql.com/](https://www.prismagraphql.com/) for a short
video demonstrating how this works in practice.

I'm very happy that more projects are exploring code-gen for GraphQL.

------
Blackstone4
Background: I've been using Typescript + graphql-yoga/apollo-server/express +
Prisma to create a GraphQL server. I'm not familiar with golang.

I found this interesting. So just to check my understanding, does this auto
generate the routing for the incoming GraphQL queries and mutations? Then you
implement the resolvers / db components?

~~~
Blackstone4
I'm also interested in hearing your thoughts on the maturity of the golang
GraphQL ecosystem?

I've mostly been looking at the JS space and there's a lot of tooling. Having
said that my experience has been that it's easy to write a simple GraphQL
server but it gets complicated fast. I've been using Prisma which does a lot
of the heavy lifting for you. It's relatively new so does come with trade-
offs.

~~~
sebastian
Check out [https://dgraph.io/](https://dgraph.io/) . I haven't had the chance
to use it yet, but I have been following its development for a while.
Definitely worth looking into.

~~~
Blackstone4
Looks interesting. Shame the syntax is GraphQL-like but not pure GraphQL.

~~~
Blackstone4
Looks like GraphQL compatibility is on the roadmap for 2018

[https://github.com/dgraph-io/dgraph/issues/1966](https://github.com/dgraph-
io/dgraph/issues/1966)

------
akmittal
Is it production ready?

