This post is not meant to be an extensive tutorial about GraphQL, it is a starting point for your own exploration into GraphQL that should give you several paths to go down and links to find out more. If you just read through this whole document in one go you will not have an understanding of GraphQL. Follow the links, try things out, and keep coming back to this page.
What is GraphQL
GraphQL is a language for querying data. With GraphQL, your existing services describe the data that they have, and clients describe the data they need.
It is often an alternative to RESTful APIs.
GraphQL started as a Facebook technology but is now part of its own foundation.
This is an old video from the early GraphQL days but the concepts are still true.
The GraphQL website has a simple tutorial to teach you GraphQL
A significant benefit of GraphQL is the client libraries and their ability to handle a significant chunk of your data layer for you. Apollo provide excellent client libraries that make caching almost effortless. If you make HTTP requests with an HTTP library (e.g. Axios, Alamofire) then you're missing out signifcantly.
Apollo also have some excellent GraphQL resources:
- A GraphQL FAQ: https://www.apollographql.com/docs/resources/faq/
- A Glossary of GraphQL terms: https://www.apollographql.com/docs/resources/graphql-glossary/
Building The Back-end
There are various libraries for other languages as well, a popular one for Golang is gqlgen:
Another common need in a backend is a 'Dataloader' - a utility to be used as part of your application’s data fetching layer to provide a consistent API over various backends (often databases) and reduce requests to those backends via batching and caching.
JS - https://github.com/graphql/dataloader
Golang - https://github.com/vektah/dataloaden
Federation / Stitching / Microservices
If you're using microservices and have several GraphQL services then you'll want to look into Apollo Federation which 'stitches' all of your services' graphs into one Graph. Federation is implemented in other GraphQL libraries too.
This article has some good design principles for building effective GraphQL mutation systems that can evolve over time:
Insomnia is an HTTP and GraphQL client for debugging APIs https://insomnia.rest/
https://graphqlweekly.com/ is a great email newsletter than sends you new articles and videos every week.