Skip to content
/ graphql Public
forked from graphql-go/graphql

An implementation of GraphQL for Go / Golang

License

Notifications You must be signed in to change notification settings

jaewie/graphql

This branch is 127 commits behind graphql-go/graphql:master.

Folders and files

NameName
Last commit message
Last commit date
Dec 2, 2018
Jul 31, 2018
Sep 21, 2019
Dec 9, 2018
Mar 10, 2019
Dec 9, 2018
Apr 2, 2017
Oct 16, 2018
Aug 15, 2015
Jul 19, 2018
Dec 9, 2018
Apr 3, 2019
Jun 11, 2018
Mar 24, 2018
Dec 9, 2018
Jul 27, 2018
Apr 2, 2019
Aug 5, 2017
Nov 25, 2015
Mar 9, 2019
Apr 2, 2019
Mar 12, 2019
Dec 2, 2018
Mar 7, 2019
Jan 6, 2018
Aug 5, 2017
Apr 3, 2019
Dec 9, 2018
Mar 11, 2016
Dec 9, 2018
Jul 19, 2018
May 13, 2016
Dec 9, 2018
Mar 15, 2017
Apr 3, 2019
Jul 31, 2018
Apr 5, 2016
Aug 5, 2017
Aug 5, 2017
Apr 11, 2016
Mar 15, 2017
Mar 15, 2017
Mar 8, 2016
Mar 15, 2017
Mar 11, 2016
Apr 11, 2016
Mar 10, 2016
Nov 18, 2015
Apr 12, 2016
Aug 5, 2017
Aug 5, 2017
Nov 18, 2015
Nov 18, 2015
Nov 18, 2015
Apr 12, 2016
Nov 18, 2015
Mar 8, 2016
Aug 5, 2017
Apr 6, 2016
Nov 18, 2015
Apr 12, 2016
Sep 17, 2019
Nov 16, 2018
Jul 23, 2017
Jul 26, 2018
May 16, 2018
Feb 21, 2019
Mar 15, 2017
Mar 15, 2017
Sep 11, 2018
Apr 2, 2019
Aug 1, 2018
Sep 11, 2018
Dec 18, 2017
May 31, 2016
Apr 13, 2018
Dec 9, 2018
Aug 1, 2018
May 25, 2018
Dec 9, 2018

Repository files navigation

graphql CircleCI GoDoc Coverage Status Join the chat at https://gitter.im/graphql-go/graphql

An implementation of GraphQL in Go. Follows the official reference implementation graphql-js.

Supports: queries, mutations & subscriptions.

Documentation

godoc: https://godoc.org/github.com/graphql-go/graphql

Getting Started

To install the library, run:

go get github.com/graphql-go/graphql

The 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.

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/graphql-go/graphql"
)

func main() {
	// Schema
	fields := graphql.Fields{
		"hello": &graphql.Field{
			Type: graphql.String,
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
				return "world", nil
			},
		},
	}
	rootQuery := graphql.ObjectConfig{Name: "RootQuery", Fields: fields}
	schemaConfig := graphql.SchemaConfig{Query: graphql.NewObject(rootQuery)}
	schema, err := graphql.NewSchema(schemaConfig)
	if err != nil {
		log.Fatalf("failed to create new schema, error: %v", err)
	}

	// Query
	query := `
		{
			hello
		}
	`
	params := graphql.Params{Schema: schema, RequestString: query}
	r := graphql.Do(params)
	if len(r.Errors) > 0 {
		log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors)
	}
	rJSON, _ := json.Marshal(r)
	fmt.Printf("%s \n", rJSON) // {“data”:{“hello”:”world”}}
}

For more complex examples, refer to the examples/ directory and graphql_test.go.

Third Party Libraries

Name Author Description
graphql-go-handler Hafiz Ismail Middleware to handle GraphQL queries through HTTP requests.
graphql-relay-go Hafiz Ismail Lib to construct a graphql-go server supporting react-relay.
golang-relay-starter-kit Hafiz Ismail Barebones starting point for a Relay application with Golang GraphQL server.
dataloader Nick Randall DataLoader implementation in Go.

Blog Posts

About

An implementation of GraphQL for Go / Golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%