Writing a GraphQL server in Go
GraphQL is an alternative to REST, created by Facebook (http://graphql.org/). This technology allows a server to implement and publish a schema and the clients then can ask for the information they need rather than understanding and making use of various API endpoints.
For this recipe, we'll create a Graphql
schema that represents a deck of playing cards. We'll expose one resource card, which can be filtered by suit and value. Alternatively, it can return all the cards in the deck if no arguments are specified.
Getting ready
Configure your environment according to these steps:
- Refer to the Getting ready section of the Goflow for dataflow programming recipe in this chapter.
- Run the
go get github.com/graphql-go/graphql
command.
How to do it...
These steps cover writing and running your application:
- From your terminal/console application, create the
chapter11/graphql
directory and navigate to it. - Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter11...