[The post is out of date, please read the update]
I previously wrote about an implementation of a GraphQL server in Java. That post is showing age because the code is part of a kata project and constantly evolves.
A Concise Example
So, I’ve created a new concise example in GitHub that exemplifies using:
- Ratpack for the server
- GraphQL Java for the GraphQL engine
- GraphQL Annotations for Java for the schema creation
The example is just the code needed to manage a list of companies in memory. It implements basic CRUD operations but with an extensible pattern.
Grab The Code
It’s all covered in ~300 lines of code:
- A package with a GraphQL Schema, using a Query and a Mutation class
- A GraphQLHandler that dispatches POST requests to GraphQL
- An Application that creates the Ratpack server for the GraphQLHandler
The README covers how to run it, and there are a series sample requests included.