Golang implementation of a GraphQL server using Cassandra, MongoDB and REST backends inspired by Tutorial: How to build a GraphQL server.
Get the code:
go get github.com/nilstgmd/graphql-starter-kit
Start the Docker container running the GraphQL server, a container with Cassandra and a container with MongoDB (showterm.io):
cd $GOPATH/src/github.com/nilstgmd/graphql-starter-kit/ && make all
Use the GraphiQL IDE in your browser http://localhost:8080/
or the API http://localhost:8080/graphql?query=...
to execute queries against the server.
Using GraphiQL:
{
author(firstName:"Rob", lastName: "Pike"){
firstName
lastName
posts{
title
views
}
}
getFortuneCookie
}
Using cURL:
curl -XPOST http://localhost:8080/graphql \
-H 'Content-Type: application/graphql' \
-d 'query Root{ author(firstName:"Andrew",lastName:"Gerrand"){firstName,lastName,posts{title,views}},getFortuneCookie }'
Just because it is cool: Flamegraphs 🔥
The GraphQL server offers a pprof endpoint which can be consumed to create flamegraphs with go-torch.