robmadden / star_wars_go

A simple Go/GraphQL/Relay example server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Star Wars Go Example

An example Golang server that uses GraphQL and Relay that serves up Star Wars data.

Taken from: Playground


Features

Useful Links

How to run Hello Go locally:

  1. Make sure you have go installed.

  2. Make sure you have GOPATH set to the directory where this project is installed:

$ export GOPATH=`pwd`
  1. Run the app:
$ go run main.go

cURL Examples

Rebel Alliance Queries

Fetch the Rebel faction name:

$ curl -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '
{
    "query": "query { rebels { name } }", 
    "variables": null
}'

Fetch the first Rebel ship:

$ curl -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '
{
    "query": "query { rebels { name ships(first: 1) { edges { node { name } } } } }",
    "variables": null
}'

Fetch all Rebel ships:

$ curl -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '
{
    "query": "query { rebels { name ships { edges { node { name } } } } }",
    "variables": null
}'

Empire Queries

Fetch the Empire faction name:

$ curl -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '
{
    "query": "query { empire { name } }", 
    "variables": null
}'

Fetch the first Empire ship:

$ curl -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '
{
    "query": "query { empire { name ships(first: 1) { edges { node { name } } } } }",
    "variables": null
}'

Fetch all Empire ships:

$ curl -X POST http://localhost:3000/graphql -H 'Content-Type: application/json' -d '
{
    "query": "query { empire { name ships { edges { node { name } } } } }",
    "variables": null
}'

Docker How To

How to do stuff with Docker.

Docker Build

$ docker build -t star_wars_go .

Docker Run

$ docker run --publish 3000:3000 --name star_wars_go --rm star_wars_go

Docker Stop

$ docker stop star_wars_go

About

A simple Go/GraphQL/Relay example server


Languages

Language:Go 100.0%