basic_graphql_server

command
Version: v0.0.0-...-3ba1e70 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2015 License: ISC Imports: 10 Imported by: 0

Documentation

Overview

Program basic_graphql_server shows a simple HTTP server that exposes a bare schema.

Example:

$ go get github.com/tallstreet/graphql/example/basic_graphql_server
$ basic_graphql_server &
$ curl -g -XPOST 'http://localhost:8080/' --data-binary '{ "query": "{__schema{root_fields{name,description}}}"}'

{

"data": {
  "__schema": {
    "root_fields": [
      {
        "description": "Schema entry root field",
        "name": "__schema"
      },
      {
        "description": "Provides the current server uptime",
        "name": "uptime"
      },
      {
        "description": "Provides the current server time",
        "name": "now"
      },
      {
        "description": "Query registered types by name",
        "name": "__type"
      }
    ]
  }
}

}

$ curl -g -XPOST 'http://localhost:8080/' --data-binary '{ "query": "query rootFields { uptime, now} "}'
{
"data": {
  "def": 177.898958761,
  "now": "2015-09-12T20:25:46.065224697+01:00"
}

} Here we see the server showing the available root fields ("schema").

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL