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

..03-May-2022-

.circleci/H05-Feb-2020-

benchutil/H05-Feb-2020-

examples/H05-Feb-2020-

gqlerrors/H05-Feb-2020-

language/H05-Feb-2020-

testutil/H05-Feb-2020-

.gitignoreH A D05-Feb-202015

CONTRIBUTING.mdH A D05-Feb-20205.9 KiB

LICENSEH A D05-Feb-20201.1 KiB

README.mdH A D05-Feb-20203.3 KiB

abstract_test.goH A D05-Feb-202013.8 KiB

definition.goH A D05-Feb-202032.6 KiB

definition_test.goH A D05-Feb-202018.2 KiB

directives.goH A D05-Feb-20204.6 KiB

directives_test.goH A D05-Feb-202013.4 KiB

enum_type_test.goH A D05-Feb-202012.8 KiB

executor.goH A D05-Feb-202031.8 KiB

executor_resolve_test.goH A D05-Feb-20207 KiB

executor_schema_test.goH A D05-Feb-20206.9 KiB

executor_test.goH A D05-Feb-202054.2 KiB

extensions.goH A D05-Feb-20208 KiB

extensions_test.goH A D05-Feb-202011.9 KiB

go.modH A D05-Feb-202037

graphql.goH A D05-Feb-20202.8 KiB

graphql_bench_test.goH A D05-Feb-20202.4 KiB

graphql_test.goH A D05-Feb-20206.3 KiB

introspection.goH A D05-Feb-202022.4 KiB

introspection_test.goH A D05-Feb-202037.3 KiB

kitchen-sink.graphqlH A D05-Feb-2020823

lists_test.goH A D05-Feb-202021.5 KiB

located.goH A D05-Feb-20201.1 KiB

mutations_test.goH A D05-Feb-20206.5 KiB

nonnull_test.goH A D05-Feb-202026.4 KiB

quoted_or_list_internal_test.goH A D05-Feb-2020991

race_test.goH A D05-Feb-20201.2 KiB

rules.goH A D05-Feb-202055.5 KiB

rules_arguments_of_correct_type_test.goH A D05-Feb-202023.3 KiB

rules_default_values_of_correct_type_test.goH A D05-Feb-20203.6 KiB

rules_fields_on_correct_type_test.goH A D05-Feb-20208.8 KiB

rules_fragments_on_composite_types_test.goH A D05-Feb-20202.8 KiB

rules_known_argument_names_test.goH A D05-Feb-20204.4 KiB

rules_known_directives_rule_test.goH A D05-Feb-20205.2 KiB

rules_known_fragment_names_test.goH A D05-Feb-20201.3 KiB

rules_known_type_names_test.goH A D05-Feb-20201.6 KiB

rules_lone_anonymous_operation_rule_test.goH A D05-Feb-20202.2 KiB

rules_no_fragment_cycles_test.goH A D05-Feb-20206.2 KiB

rules_no_undefined_variables_test.goH A D05-Feb-20208 KiB

rules_no_unused_fragments_test.goH A D05-Feb-20203.1 KiB

rules_no_unused_variables_test.goH A D05-Feb-20205.2 KiB

rules_overlapping_fields_can_be_merged.goH A D05-Feb-202024.8 KiB

rules_overlapping_fields_can_be_merged_test.goH A D05-Feb-202026.4 KiB

rules_possible_fragment_spreads_test.goH A D05-Feb-20208.2 KiB

rules_provided_non_null_arguments_test.goH A D05-Feb-20205.6 KiB

rules_scalar_leafs_test.goH A D05-Feb-20203.1 KiB

rules_unique_argument_names_test.goH A D05-Feb-20203.6 KiB

rules_unique_fragment_names_test.goH A D05-Feb-20202.2 KiB

rules_unique_input_field_names_test.goH A D05-Feb-20201.9 KiB

rules_unique_operation_names_test.goH A D05-Feb-20202.8 KiB

rules_unique_variable_names_test.goH A D05-Feb-20201 KiB

rules_variables_are_input_types_test.goH A D05-Feb-2020918

rules_variables_in_allowed_position_test.goH A D05-Feb-20208 KiB

scalars.goH A D05-Feb-202010.8 KiB

scalars_parse_test.goH A D05-Feb-20201.4 KiB

scalars_serialization_test.goH A D05-Feb-20204.9 KiB

scalars_test.goH A D05-Feb-202010 KiB

schema-kitchen-sink.graphqlH A D05-Feb-20201.3 KiB

schema.goH A D05-Feb-202014.5 KiB

suggested_list_internal_test.goH A D05-Feb-2020821

type_comparators_internal_test.goH A D05-Feb-20204 KiB

type_info.goH A D05-Feb-20207.6 KiB

types.goH A D05-Feb-2020537

union_interface_test.goH A D05-Feb-202014.1 KiB

util.goH A D05-Feb-20203.5 KiB

util_test.goH A D05-Feb-20203.9 KiB

validation_test.goH A D05-Feb-202048.2 KiB

validator.goH A D05-Feb-20208.6 KiB

validator_test.goH A D05-Feb-20202.5 KiB

values.goH A D05-Feb-202011.4 KiB

values_test.goH A D05-Feb-2020461

variables_test.goH A D05-Feb-202036.3 KiB

README.md

1# graphql [![CircleCI](https://circleci.com/gh/graphql-go/graphql/tree/master.svg?style=svg)](https://circleci.com/gh/graphql-go/graphql/tree/master) [![GoDoc](https://godoc.org/graphql.co/graphql?status.svg)](https://godoc.org/github.com/graphql-go/graphql) [![Coverage Status](https://coveralls.io/repos/github/graphql-go/graphql/badge.svg?branch=master)](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](https://wehavefaces.net/learn-golang-graphql-relay-1-e59ea174a902)
75
76