/graphql-starter-kit

A GraphQL server example written in GoLang integrating with Cassandra and MongoDB.

Primary LanguageCSSApache License 2.0Apache-2.0

GraphQL Starter Kit for GoLang

Golang implementation of a GraphQL server using Cassandra, MongoDB and REST backends inspired by Tutorial: How to build a GraphQL server.

Quick Start

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.

GraphiQL IDE

Example

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 }'

Extra

Just because it is cool: Flamegraphs 🔥

Flamegraph

The GraphQL server offers a pprof endpoint which can be consumed to create flamegraphs with go-torch.