• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Jul-2019-

gqlerrors/H18-Jul-2019-262224

language/H18-Jul-2019-5,6564,765

testutil/H18-Jul-2019-1,1911,145

.gitignoreH A D18-Jul-201915 22

.travis.ymlH A D18-Jul-2019276 2015

CONTRIBUTING.mdH A D18-Jul-20195.9 KiB140102

LICENSEH A D18-Jul-20191.1 KiB2217

README.mdH A D18-Jul-20193.2 KiB7660

definition.goH A D18-Jul-201932.4 KiB1,3411,004

directives.goH A D18-Jul-20194.6 KiB157126

executor.goH A D18-Jul-201925.6 KiB910750

graphql.goH A D18-Jul-20191.6 KiB6441

introspection.goH A D18-Jul-201921.8 KiB764686

kitchen-sink.graphqlH A D18-Jul-2019823 5347

located.goH A D18-Jul-2019714 3834

rules.goH A D18-Jul-201955.7 KiB1,9081,625

rules_overlapping_fields_can_be_merged.goH A D18-Jul-201924.7 KiB707473

scalars.goH A D18-Jul-20197.3 KiB330300

schema-kitchen-sink.graphqlH A D18-Jul-20191.3 KiB7152

schema.goH A D18-Jul-201914.6 KiB567450

type_info.goH A D18-Jul-20197.7 KiB277241

types.goH A D18-Jul-2019298 1711

util.goH A D18-Jul-20193.5 KiB181152

validator.goH A D18-Jul-20198.6 KiB289237

values.goH A D18-Jul-201912.3 KiB477400

README.md

1# graphql [![Build Status](https://travis-ci.org/graphql-go/graphql.svg)](https://travis-ci.org/graphql-go/graphql) [![GoDoc](https://godoc.org/graphql.co/graphql?status.svg)](https://godoc.org/github.com/graphql-go/graphql) [![Coverage Status](https://coveralls.io/repos/graphql-go/graphql/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-go/graphql?branch=master) [![Join the chat at https://gitter.im/graphql-go/graphql](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/graphql-go/graphql?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
3An implementation of GraphQL in Go. Follows the official reference implementation [`graphql-js`](https://github.com/graphql/graphql-js).
4
5Supports: queries, mutations & subscriptions.
6
7### Documentation
8
9godoc: https://godoc.org/github.com/graphql-go/graphql
10
11### Getting Started
12
13To install the library, run:
14```bash
15go get github.com/graphql-go/graphql
16```
17
18The following is a simple example which defines a schema with a single `hello` string-type field and a `Resolve` method which returns the string `world`. A GraphQL query is performed against this schema with the resulting output printed in JSON format.
19
20```go
21package main
22
23import (
24	"encoding/json"
25	"fmt"
26	"log"
27
28	"github.com/graphql-go/graphql"
29)
30
31func main() {
32	// Schema
33	fields := graphql.Fields{
34		"hello": &graphql.Field{
35			Type: graphql.String,
36			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
37				return "world", nil
38			},
39		},
40	}
41	rootQuery := graphql.ObjectConfig{Name: "RootQuery", Fields: fields}
42	schemaConfig := graphql.SchemaConfig{Query: graphql.NewObject(rootQuery)}
43	schema, err := graphql.NewSchema(schemaConfig)
44	if err != nil {
45		log.Fatalf("failed to create new schema, error: %v", err)
46	}
47
48	// Query
49	query := `
50		{
51			hello
52		}
53	`
54	params := graphql.Params{Schema: schema, RequestString: query}
55	r := graphql.Do(params)
56	if len(r.Errors) > 0 {
57		log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors)
58	}
59	rJSON, _ := json.Marshal(r)
60	fmt.Printf("%s \n", rJSON) // {“data”:{“hello”:”world”}}
61}
62```
63For more complex examples, refer to the [examples/](https://github.com/graphql-go/graphql/tree/master/examples/) directory and [graphql_test.go](https://github.com/graphql-go/graphql/blob/master/graphql_test.go).
64
65### Third Party Libraries
66| Name          | Author        | Description  |
67|:-------------:|:-------------:|:------------:|
68| [graphql-go-handler](https://github.com/graphql-go/graphql-go-handler) | [Hafiz Ismail](https://github.com/sogko) | Middleware to handle GraphQL queries through HTTP requests. |
69| [graphql-relay-go](https://github.com/graphql-go/graphql-relay-go) | [Hafiz Ismail](https://github.com/sogko) | Lib to construct a graphql-go server supporting react-relay. |
70| [golang-relay-starter-kit](https://github.com/sogko/golang-relay-starter-kit) | [Hafiz Ismail](https://github.com/sogko) | Barebones starting point for a Relay application with Golang GraphQL server. |
71| [dataloader](https://github.com/nicksrandall/dataloader) | [Nick Randall](https://github.com/nicksrandall) | [DataLoader](https://github.com/facebook/dataloader) implementation in Go. |
72
73### Blog Posts
74- [Golang + GraphQL + Relay](http://wehavefaces.net/)
75
76