Choosing a GraphQL server library in Go

Daishi Kato
Jul 12, 2018 · 3 min read

In this short article, I compare various Go libraries to build a GraphQL server by mainly reading the documentation and some of source code. Please note that this is my personal opinion at the time of writing which may or may not be changed over time.


Apollo Client is one of my favorite libraries recently to create React apps. React Apollo allows us to develop an app handy with GraphQL. As a GraphQL server, Apollo Server is a good option in this ecosystem, or if you want it without coding, BaaS such as AppSync and Prisma should be a good option too. Nevertheless, for some reason, I try to use Go for a GraphQL server, and I look for libraries to help developing a GraphQL server.



Comments on each library

The first one is probably the oldest one. It says:

Follows the official reference implementation graphql-js.

The resolver example in README is:

This looks like dynamic typing and it might not fit well with static typing in Go. There’s a third-party library graphql-go-handler, which supports GraphiQL and Playground.

The second one seems getting attention recently. The resolver is written as a method like:

This looks familiar. Although GraphiQL is not included, which I agree is a good decision, the example code shows how easy it is.

The names of the struct fields have to be exported and have to match the names of the GraphQL arguments in a non-case-sensitive way.

One thing I concern is this case insensitivity, which is not very intuitive at least to me.

The third is an exiting one.

Thunder generates resolvers automatically from Go struct types and function definitions.

This sounds very promising.

This is a resolver, which looks straightforward.

If you’re adventurous, please give it a try.

Besides its immaturity, my concern could be this reflection-based approach is slightly apart from Apollo Server in my mind. Maybe, just a trade-off.

The forth one says:

Its aim is to be the fastest GraphQL implementation.

This should be one of good properties.

This doesn’t look very appealing. In addition, unfortunately, the project is not active recently while having some missing functionality still to be implemented.

The fifth one is a bit different because it’s a generator.

gqlgen is golang library for building graphql servers without any fuss.

It generates template code from a schema definition and all you need is to write resolvers.

This is a resolver, which makes sense. I’m not used to such generators and personally hesitates writing configurations in YAML, but I’m pretty sure this may work well for certain people.

Conclusion at this point

After looking through 5 candidates above, two possibilities for me are graph-gophers’ graphql-go and samsarahq’s thunder. I pretty much like the thunder approach and I can imagine how easy it is to code a simple example. However, I can’t predict how well it goes in long-term period. The minimal API approach of graphql-go seems to last long. So, at this point, I choose graph-gophers’ graphql-go.

Open GraphQL

Anything & Everything GraphQL

Daishi Kato

Written by

A freelance programmer. I’m interested in working remotely with people abroad:

Open GraphQL

Anything & Everything GraphQL

Daishi Kato

Written by

A freelance programmer. I’m interested in working remotely with people abroad:

Open GraphQL

Anything & Everything GraphQL

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store