An implementation of GraphQL for Go / Golang

Overview

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://pkg.go.dev/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

Comments
  • Subscription execution

    Subscription execution

    Adds subscription execution support and a Subscribe resolver to Field and FieldDefinition types

    Resolves https://github.com/graphql-go/graphql/issues/242

    opened by bhoriuchi 28
  • Resolve fields asyncronously

    Resolve fields asyncronously

    Modified executeFields to resolve each field in their own go routine.

    I suspect that this may be the intended behaviour because it is just a copy of executeFieldsSerially right now.

    opened by ssttevee 25
  • Adding extra fields to errors

    Adding extra fields to errors

    Let's say I have a graphql schema with a field that looks like this:

    fields := graphql.Fields{
            "hello": &graphql.Field{
                Type: graphql.String,
                Resolve: func(p graphql.ResolveParams) (interface{}, error) {
                    return nil, errors.New("Whoops! An error occurred")
                },
            },
        }
    

    The result would be:

    {
      "data": {
        "test": {
          "id": null,
        }
      },
      "errors": [
        {
          "message": "Whoops! An error occurred",
          "locations": [
          ]
        }
      ]
    }
    

    What I would like to do is to be able to add extra fields to the errors object. For example:

    {
      "data": {
        "test": {
          "id": null,
        }
      },
      "errors": [
        {
          "message": "Whoops! An error occurred",
          "locations": [
          ],
          "field": "hello",
          "code": "WHOOPS_ERROR"
        }
      ]
    }
    

    It would be really cool if there's way to be able to add these extra fields into the error message when an error happens.

    enhancement 
    opened by F21 25
  • Experimental/Need feedback: Implement pluggable batching/dedup/concurrent fetch like facebook/dataloader

    Experimental/Need feedback: Implement pluggable batching/dedup/concurrent fetch like facebook/dataloader

    I have been considering how to implement the idea of facebook/dataloader with graphql in go (which address issues like #106, #132), and this PR shows the progress so far.

    This PR is mainly a demonstration on how it could work. And so far I'm happy with the idea.

    This requires some minimum changes to the graphql package (just to inject a executor with a simple interface). The real concurrency feature is implemented in the godataloader library that I wrote separately, which can be plugged into graphql.

    examples/dataloader contains an actual example, which demonstrate the following features:

    • Opt-in.
    • Concurrently loading multiple data.
    • Load duplicate requests once.
    • Batching multiple requests.
    • No unnecessary goroutines are spawn unless concurrency actually happen.
    • Synchronous programming style (without Promise-like object).

    The test might best demonstrate the behavior.

    func TestQuery(t *testing.T) {
        schema := dataloaderexample.CreateSchema()
        r := dataloaderexample.RunQuery(`{
            p1_0: post(id: "1") { id author { name }}
            p1_1: post(id: "1") { id author { name }}
            p1_2: post(id: "1") { id author { name }}
            p1_3: post(id: "1") { id author { name }}
            p1_4: post(id: "1") { id author { name }}
            p1_5: post(id: "1") { id author { name }}
            p2_1: post(id: "2") { id author { name }}
            p2_2: post(id: "2") { id author { name }}
            p2_3: post(id: "2") { id author { name }}
            p3_1: post(id: "3") { id author { name }}
            p3_2: post(id: "3") { id author { name }}
            p3_3: post(id: "3") { id author { name }}
            u1_1: user(id: "1") { name }
            u1_2: user(id: "1") { name }
            u1_3: user(id: "1") { name }
            u2_1: user(id: "3") { name }
            u2_2: user(id: "3") { name }
            u2_3: user(id: "3") { name }
        }`, schema)
        if len(r.Errors) != 0 {
            t.Error(r.Errors)
        }
        t.Error(r)
        // The above query would produce log like this:
        // 2016/07/23 23:49:31 Load post 3
        // 2016/07/23 23:49:31 Load post 1
        // 2016/07/23 23:49:31 Load post 2
        // 2016/07/23 23:49:32 Batch load users [3 1 2]
        // Notice the first level post loading is done concurrently without duplicate.
        // The user loading is also done in the same fashion, but batched fetch is used instead.
        // TODO: Make test actually verify the logged behavior.
    }
    

    This PR is not meant to be merged yet (at least the example probably doesn't fit to be part of this project because of its external dependency, unless the godataloader library is moved).

    The godataloader library is probably a little bit more complicated than one would expect. And I'm happy to explain it if anyone finds this idea interesting.

    opened by bigdrum 21
  • Concurrently resolve fields

    Concurrently resolve fields

    This PR addresses #106 and probably #119. This also depends on PR #123 and has updated with changes from that PR.

    Relevant commits specifically for this PR: (The other commits are not related to this PR)


    https://github.com/graphql-go/graphql/commit/09574d6faa9ef710320137f0fc9b1e4d02c6e2f6 Ensure rw-safety of ExecutionContext.errors which will be read/written by multiple routines/threads later

    Uses sync.RWMutex to ensure safety of ExecutionContext.errors.

    If the executor encounters errors while resolving fields (e.g. from recovering from panic or when ResolveFn returns an error), it will collect it and add to a list of errors, which will then be returned in graphql.Result.

    Since this will be done concurrently if we use go-routines to resolve fields, this has to be thread-safe.


    https://github.com/graphql-go/graphql/commit/ab3b083f9119b0aaf8c98ec716524dcf1c231780 Experimental implementation of concurrently resolving fields

    This change is contained in executeFields(...).

    For each field to be resolved, create a go-routine to resolve a field. sync.WaitGroup is used to wait for all fields to complete. This will happen for each field that has sub-fields as well.

    Given the following query:

    query Bar {
      article {
        id
        author {
          id
          name
        }
      }
      feed {
        title
        body
        author {
          id
          name
        }
      }
    }
    
      Bar ---> article ---> id
          |           |
          |            --> author ---> id
          |                      |
          |                       ---> name
          ---> feed ---> title
                    |
                    ---> body
                    |
                    ---> author ---> id
                                |
                                ---> name
    
    1. article and feed will be resolved concurrently.
    2. Within article: id and author will be resolved concurrently.
    3. Within article.author: id and name will be resolved concurrently.
    4. Within feed: title, body and author will be resolved concurrently.
    5. Within feed.author: id and name will be resolved concurrently.

    Cheers!

    enhancement 
    opened by sogko 19
  • Added Custom Error Formatter

    Added Custom Error Formatter

    I added support for a custom error formatter. Sometimes you come with custom error objects that might need special parsing to add correct extensions in a generic way by object type.

    This implementation doesn't change anything to the flow if no Custom Handler is specified since it uses by default the FormatError method. However if you specify, it will run your custom function expecting a FormattedError to return.

    Just a quick example:

    func CustomFormat(err error) gqlerrors.FormattedError {
    	switch err := err.(type) {
    	case *gqlerrors.Error:
                    // My custom error object returned in the mutation / query is encapsulated as OriginalError
    		cf := CustomFormat(err.OriginalError)
    		cf.Locations = err.Locations
    		cf.Path = err.Path
    		return cf
    	case *QuantoError.ErrorObject:
                    // Here I can call my custom ErrorObject ToFormattedError that will return an FormattedError with proper extensions set.
    		return err.ToFormattedError()
    	default:
    		return gqlerrors.FormatError(err)
    	}
    }
    

    Then you can use something like:

    	// execute graphql query
    	params := graphql.Params{
    		Schema:         		*h.Schema,
    		RequestString:  		opts.Query,
    		VariableValues: 		opts.Variables,
    		OperationName:  		opts.OperationName,
    		Context:        		ctx,
    		CustomErrorFomatter: 	CustomFormat,
    	}
    	result := graphql.Do(params)
    

    And everything will work.

    I'm also opening a PR in graphql-go/handler since it also benefits in this custom handler. I will put a example there as well.

    opened by racerxdl 18
  • Subscription support

    Subscription support

    Some initial work has been done to implement subscriptions in graphql-js: https://github.com/graphql/graphql-js/pull/189

    Here's the relay discussion for getting support into relay: https://github.com/facebook/relay/issues/541

    Would love to see this subscriptions land here once they are in the reference implementation :smile:

    question 
    opened by F21 17
  • Create basic example follow http://graphql.org/docs/getting-started/

    Create basic example follow http://graphql.org/docs/getting-started/

    Just port a simple example from JS into GoLang follow http://graphql.org/docs/getting-started/ I hope it will make everyone easy to start to learn about Graphql by using graphql-go and understand how to port js schema sources into Golang

    opened by thanhliem89dn 17
  • API Improvement.

    API Improvement.

    Before releasing the first version of the lib, I think we could improve the API, meaning remove verbosity and clean-it-up to be go-idiomatic, so please do share ur thoughts on this! :+1:

    This is the basic example from the Getting Started section on README (still to merge #43):

    package main
    
    import (
        "encoding/json"
        "fmt"
        "log"
    
        "github.com/chris-ramon/graphql"
    )
    
    func main() {
        // Schema
        fields := graphql.FieldConfigMap{
            "hello": &graphql.FieldConfig{
                Type: graphql.String,
                Resolve: func(p graphql.GQLFRParams) interface{} {
                    return "world"
                },
            },
        }
        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}
        result := make(chan *graphql.Result)
        go graphql.Graphql(params, result)
        r := <-result
        if len(r.Errors) > 0 {
            log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors)
        }
    }
    

    My initial proposal is:

    package main
    
    import (
        "encoding/json"
        "fmt"
        "log"
    
        "github.com/chris-ramon/graphql"
    )
    
    func main() {
        // Schema
        helloResolve := func(p graphql.ResolveParams) interface{} {
            return "world"
        }
        fields := []graphql.Fields{
            graphql.Field{Name: "hello", Type: graphql.String, Resolve: helloResolve},
        }
        schema, err := graphql.NewSchema(Name: "RootQuery", Fields: fields)
        if err != nil {
            log.Fatalf("failed to create new schema, error: %v", err)
        }
    
        // Query
        query := `{hello}`
        result := make(chan *graphql.Result)
        go graphql.Do(schema, query, result) // Like: http.Client.Do
        r := <-result
        if len(r.Errors) > 0 {
            log.Fatalf("failed to execute graphql operation, errors: %+v", r.Errors)
        }
    }
    
    enhancement discussion 
    opened by chris-ramon 15
  • Rally community...

    Rally community...

    Browsing around it looks like the go-graphql landscape is still in its infancy, however graphql-go seems to be one of the more referenced libs out there. I'm looking at using it in my own work and would potentially be happy to start contributing, but it would be helpful to sketch out some a bit more detailed roadmap and near-term goals so potential contributors can see what to focus on.

    meta 
    opened by EmergentBehavior 15
  • Add BindFields function tool

    Add BindFields function tool

    I've been working with graphql-go lately and realize I'm pretty lazy to create object type for every struct I had. So I made a binder/wrapper function to easily bind all fields in my struct into graphql object.

    So if you have this struct

    type Person struct {
        Name    string  `graph:"name"`
        Address string  `graph:"address"`
    }
    

    you can create person type with

    personType := graphql.NewObject(graphql.ObjectConfig{
            Name:   "Person",
            Fields: BindFields(Person{}),
        })
    

    in file util_test.go I made an example with Person struct that looked like this:

    type Person struct {
    	Human //embedded Fields
    	Name    string   `json:"name"` // standard scalar type
    	Home    Address  `json:"home"` // struct type
    	Hobbies []string `json:"hobbies"` // slice of scalar type 
    	Friends []Friend `json:"friends"` // slice of struct type
    }
    
    type Human struct {
    	Alive  bool    `json:"alive"`
    	Age    int     `json:"age"`
    	Weight float64 `json:"weight"`
    }
    
    type Friend struct {
    	Name    string `json:"name"`
    	Address string `json:"address"`
    }
    
    type Address struct {
    	Street string `json:"street"`
    	City   string `json:"city"`
    }
    

    because this function will scan through empty struct so this function cannot accept recursive type. that would make a stack-overflow error. And one more utility function which is BindArgs that can bind the args depending on provided params.

    opened by jekiapp 14
  • Kitchen Sink Schema is Invalid

    Kitchen Sink Schema is Invalid

    https://github.com/graphql-go/graphql/blob/09272f35006712d597c0446258874ce7ff8919fb/schema-kitchen-sink.graphql#L61

    The statement extend type Foo @onType {} is invalid -- the grammar does not allow an empty FieldsDefinition.

    opened by polarina 0
  • DateTime field is not serialized in output

    DateTime field is not serialized in output

    If i have a schema with DateTime type field as submit a map to resolve:

     time: "2021-11-12T12:43:56+00:00"
    

    it does not work, as always assumes to have time.Time or *time.Time

    This behaviour is not convinent when reading JSON from other sources.

    For Boolean "true" works same as Bool, but for some reason conversion from string to DateTime is not supported

    opened by astudnev 1
  • Aliases are not supported in map keys

    Aliases are not supported in map keys

    when i query

    {
        hello{
            alias1: id
            alias2: id
        }
    }
    

    and submit the map

    {
        hello{
            alias1: "1"
            alias2: "2"
        }
    }
    

    it returns nil for both aliases

    Expected result is alias1 :"1" and "alias2": "2"

    There is another case... when i query

    {
        hello{
            id
            alias2: id
        }
    }
    

    and submit the map

    {
        hello{
            id: "1"
           alias2: "2"
        }
    }
    

    it returns alias2: "1" and id: "1"

    Expected result is id :"1" and "alias2": "2"

    both results are wrong!

    It may be covered in PR https://github.com/graphql-go/graphql/pull/630 but i have not tested all possible cases

    opened by astudnev 0
  • could not resolved all fields in input argument in ResolveParams.Args

    could not resolved all fields in input argument in ResolveParams.Args

    When I request a mutation to my graphql server(using graphql-go) but i didn't get all the fields of the argument cart.

    mutation($user_id: Int, $session_id: String, $product_id: Int!, $quantity: Int!, $cart: CartInput) {
           add_to_cart(user_id: $user_id, session_id: $session_id, product_id: $product_id, quantity: $quantity, cart: $cart) {
    
              ... some fields ...
    
           }
    }
    

    But graphql resolve 3 fields of the 12 fields.

    func addToCart(params graphql.ResolveParams) (interface{}, error) {
    	u_id, uOk := params.Args["user_id"].(int)
    	s_id, _ := params.Args["session_id"].(string)
    	p_id, _ := params.Args["product_id"].(int)
    	quant, _ := params.Args["quantity"].(int)
    	cartarg, cartOk := params.Args["cart"].(model.Cart)
           //cartOk - false !
    
            fmt.Println("cart Args:", params.Args["cart"]) 
            
           // -> cart Args:map[extra_large_cart:false items:[<nil>] not_selected:[]]
    }
    

    CartInput

    var CartInputType = graphql.NewInputObject(graphql.InputObjectConfig{
    	Name: "CartInput",
    	Fields: graphql.InputObjectConfigFieldMap{
    		"promo": &graphql.InputObjectFieldConfig{
    			Type: CartPromoType,
    		},
    		"extra_large_cart": &graphql.InputObjectFieldConfig{
    			Type: graphql.Boolean,
    		},
    		"items": &graphql.InputObjectFieldConfig{
    			Type: graphql.NewList(ProductType),
    		},
    		"not_selected": &graphql.InputObjectFieldConfig{
    			Type: graphql.NewList(ProductType),
    		},
    		"delivery_data": &graphql.InputObjectFieldConfig{
    			Type: CartServiceType,
    		},
    		"bonuses": &graphql.InputObjectFieldConfig{
    			Type: graphql.Float,
    		},
    		"date": &graphql.InputObjectFieldConfig{
    			Type: graphql.String,
    		},
    		"name": &graphql.InputObjectFieldConfig{
    			Type: graphql.String,
    		},
    		"surname": &graphql.InputObjectFieldConfig{
    			Type: graphql.String,
    		},
    		"patronymic": &graphql.InputObjectFieldConfig{
    			Type: graphql.String,
    		},
    		"phone": &graphql.InputObjectFieldConfig{
    			Type: graphql.String,
    		},
    		"email": &graphql.InputObjectFieldConfig{
    			Type: graphql.String,
    		},
    	},
    },
    )
    
    opened by ielyanov 0
  • serveWS undefined

    serveWS undefined

    Hello. I get an error if I build a graphql server with golang version 1.19

    go build -o mona-agent
    # github.com/andrewwphillips/eggql/internal/handler
    ../../go/pkg/mod/github.com/andrewwphillips/[email protected]/internal/handler/handler.go:92:5: h.serveWS undefined (type *Handler has no field or method serveWS)
    make: *** [Makefile:7: build] Error 2
    

    What's going wrong here?

    opened by wlmost 0
Releases(v0.8.0)
  • v0.8.0(Aug 29, 2021)

    • subscription: graphql.Subscribe implementation @ https://github.com/graphql-go/graphql/pull/495
    • language/printer: string quoting fix @ https://github.com/graphql-go/graphql/pull/587
    • README: replaces https://godoc.org in favor of https://pkg.go.dev links @ https://github.com/graphql-go/graphql/pull/593 & https://github.com/graphql-go/graphql/pull/591
    • {executor,schema}: use invariantf for performance improvement @ https://github.com/graphql-go/graphql/pull/590
    • examples/sql-nullstring: fix error handling @ https://github.com/graphql-go/graphql/pull/569
    • examples: adds http-post example @ https://github.com/graphql-go/graphql/pull/575
    • examples/todo/schema: TodoSchema @ https://github.com/graphql-go/graphql/pull/574
    • definition: fix error handling @ https://github.com/graphql-go/graphql/pull/561
    • util: encoding.TextMarshaler support for BindFields @ https://github.com/graphql-go/graphql/pull/503
    • graphql: typo fix @ https://github.com/graphql-go/graphql/pull/551
    • language/printer: description printing support @ https://github.com/graphql-go/graphql/pull/485
    Source code(tar.gz)
    Source code(zip)
  • v0.7.9(Feb 8, 2020)

    • executor: better error handling @ #459
    • introspection: ensuring fields & interfaces initialization @ #469
    • docs: formatting & link fixes @ #487, #497
    • tests: example of a query with variables @ #491
    • executor: ordered execution of mutations @ #493
    • examples: sql.NullString scalar example @ #501
    • scalars: bitsize increased to 64 when parsing literals for floats @ #511
    • examples/crud: better formatting @ #512
    • testutil: test data fix @ #513
    • rules: better check of overlapping fields @ #521
    • scalars: un-serialization of time.Time support for DateTime @ #523
    • introspection: fixes false-positive deprecation of fields @ #524
    • extensions: better capture of errors for resolveFieldFinishFn @ #526
    Source code(tar.gz)
    Source code(zip)
  • v0.7.8(Mar 28, 2019)

    • add extensions support @ #448
    • lexer: fixes panic on empty blockstrings @ #456
    • lexer: simplify lexer.TokenType @ #433
    • resolvers: support custom map types @ #440
    • thread-safety: added Result.AppendErrors @ #434
    • fix panic when mutations or subscriptions are not configured @ #431
    • errors: consolidates original error for re-usability @ #427
    Source code(tar.gz)
    Source code(zip)
  • v0.7.7(Dec 3, 2018)

    • null pointer improvements for lists @ https://github.com/graphql-go/graphql/pull/377
    • concurrent resolvers support @ https://github.com/graphql-go/graphql/pull/388
    • concurrent resolvers example @ https://github.com/graphql-go/graphql/pull/394
    • thunk signature improvements @ https://github.com/graphql-go/graphql/pull/393
    • code improvements via go-critic [email protected] https://github.com/graphql-go/graphql/pull/395
    • graphql-js sync: Public ResolveInfo.Path @ https://github.com/graphql-go/graphql/pull/403
    • docs improvements @ https://github.com/graphql-go/graphql/pull/407
    • graphql.DateTime improvements @ https://github.com/graphql-go/graphql/pull/419
    • circleci: go modules support @ https://github.com/graphql-go/graphql/pull/425
    • graphql-js sync: FormattedError.OriginalError support @ https://github.com/graphql-go/graphql/pull/423
    Source code(tar.gz)
    Source code(zip)
  • v0.7.6(Aug 19, 2018)

    • Code improvements via go-critic @ https://github.com/graphql-go/graphql/pull/376, https://github.com/graphql-go/graphql/pull/375, https://github.com/graphql-go/graphql/pull/374, https://github.com/graphql-go/graphql/pull/373 & https://github.com/graphql-go/graphql/pull/372
    • enum nil pointer safety @ https://github.com/graphql-go/graphql/pull/370
    • scalar nil pointer safety @ https://github.com/graphql-go/graphql/pull/369
    • examples: Products CRUD @ https://github.com/graphql-go/graphql/pull/368
    • errors: extensions support @ https://github.com/graphql-go/graphql/pull/363 & https://github.com/graphql-go/graphql/pull/364
    • coveralls: Badge status updated @ https://github.com/graphql-go/graphql/pull/362
    • ci: TravisCI replaced by CircleCI @ https://github.com/graphql-go/graphql/pull/361
    • examples: Context modification @ https://github.com/graphql-go/graphql/pull/350
    • examples: Custom scalar type @ https://github.com/graphql-go/graphql/pull/346
    • scalars: coerceFloat improvement @ https://github.com/graphql-go/graphql/pull/352
    • scalars: Test coverage improved for coercion @ https://github.com/graphql-go/graphql/pull/342
    • thunks: Regression fixes @ https://github.com/graphql-go/graphql/pull/341
    • gofmt @ https://github.com/graphql-go/graphql/pull/335
    • scalars: Update float coersion double-precision @ https://github.com/graphql-go/graphql/pull/334
    • Added AddFieldConfig method to InputObjects @ https://github.com/graphql-go/graphql/pull/332
    • executor: Iterable improvements @ https://github.com/graphql-go/graphql/pull/327
    • interfaces: Support for & @ https://github.com/graphql-go/graphql/pull/324
    • Code clean-up @ https://github.com/graphql-go/graphql/pull/321, https://github.com/graphql-go/graphql/pull/319, https://github.com/graphql-go/graphql/pull/313, https://github.com/graphql-go/graphql/pull/307, https://github.com/graphql-go/graphql/pull/304, https://github.com/graphql-go/graphql/pull/294
    • typo fixes @ https://github.com/graphql-go/graphql/pull/320
    • Performance optimizations @ https://github.com/graphql-go/graphql/pull/314
    • BindFields: Pointers support @ https://github.com/graphql-go/graphql/pull/311
    • errors: Better error messages for empty {}and () @ https://github.com/graphql-go/graphql/pull/310
    • executor: DefaultResolveFn improvements @ https://github.com/graphql-go/graphql/pull/305
    • executor: resolvers as pointer methods support @ https://github.com/graphql-go/graphql/pull/302
    Source code(tar.gz)
    Source code(zip)
  • v0.7.5(Mar 8, 2018)

    • README: minor introduction improvements @ https://github.com/graphql-go/graphql/pull/270
    • travis: adds -race flag to coveralls running cmd @ https://github.com/graphql-go/graphql/pull/278
    • definition: ignore Resolve FieldResolveFn from JSON export @ https://github.com/graphql-go/graphql/pull/284
    • executor: adds optional FieldResolver @ https://github.com/graphql-go/graphql/pull/288
    • travis: adds go1.10.x @ https://github.com/graphql-go/graphql/pull/289
    Source code(tar.gz)
    Source code(zip)
  • v0.7.4(Jan 7, 2018)

    • travis: run tests against go 1.9.x & 1.8.x, removes unused cover pkg @ https://github.com/graphql-go/graphql/pull/249/files
    • block string support @ https://github.com/graphql-go/graphql/pull/261
    • schema definition language support @ https://github.com/graphql-go/graphql/pull/262
    • fix for JSON struct tags @ https://github.com/graphql-go/graphql/pull/264/files
    • perf. optimizations @ https://github.com/graphql-go/graphql/pull/265
    • hide internal types @ https://github.com/graphql-go/graphql/pull/266
    • invariantf @ https://github.com/graphql-go/graphql/pull/267
    • benchmarks @ https://github.com/graphql-go/graphql/pull/268
    Source code(tar.gz)
    Source code(zip)
  • v0.7.3(Sep 28, 2017)

    • testutil fixes @ https://github.com/graphql-go/graphql/pull/240/files
    • minor syntax improvements @ https://github.com/graphql-go/graphql/pull/244
    • contribute guideline improvements @ https://github.com/graphql-go/graphql/pull/246
    • run tests against go1.8, go1.9, travis improvements @ https://github.com/graphql-go/graphql/pull/245
    • docs improvements @ https://github.com/graphql-go/graphql/pull/247
    Source code(tar.gz)
    Source code(zip)
  • v0.7.2(Aug 6, 2017)

    v0.7.2

    • graphql-js parity v0.6.0.
    • go-fuzz nil panic fixes @ https://github.com/graphql-go/graphql/pull/223 https://github.com/graphql-go/graphql/pull/224
    • sort fields by name for better reading on introspection @ https://github.com/graphql-go/graphql/pull/225
    • fixes for input object default values @ https://github.com/graphql-go/graphql/pull/226
    • exposes default resolve function outside the lib @ https://github.com/graphql-go/graphql/pull/227
    • empty string improvements @ https://github.com/graphql-go/graphql/pull/228
    • cyclic fields support @ https://github.com/graphql-go/graphql/pull/229
    Source code(tar.gz)
    Source code(zip)
  • v0.7.1(Jul 24, 2017)

    v0.7.1

    • graphql-js parity v0.6.0.
    • std's lib context @ https://github.com/graphql-go/graphql/pull/214
    • no dependencies @ https://github.com/graphql-go/graphql/pull/218
    • date time scalar @ https://github.com/graphql-go/graphql/pull/219
    • enum type pointer values @ https://github.com/graphql-go/graphql/pull/220
    • gqlerrors nil nodes check @ https://github.com/graphql-go/graphql/pull/221
    • add types on runtime @https://github.com/graphql-go/graphql/pull/195
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Jul 23, 2017)

    Please use this version if using < Go 1.7

    • graphql-js parity v0.6.0.
    • examples improvements @ https://github.com/graphql-go/graphql/pull/216, https://github.com/graphql-go/graphql/pull/190, https://github.com/graphql-go/graphql/pull/181
    • empty string @ https://github.com/graphql-go/graphql/pull/201
    • fix string pointer @ https://github.com/graphql-go/graphql/pull/199
    • readme improvements @ https://github.com/graphql-go/graphql/pull/198, https://github.com/graphql-go/graphql/pull/191
    • binding fields util @ https://github.com/graphql-go/graphql/pull/197
    • parity graphq-js v0.6.0 @ https://github.com/graphql-go/graphql/pull/192
    • vendoring @ https://github.com/graphql-go/graphql/pull/188
    • context deadline @ https://github.com/graphql-go/graphql/pull/185
    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jan 28, 2017)

    This release brings up graphql-go on par with graphql-js v0.5.0 and fully compliant with April 2016 spec.

    Note: This release was retroactively added.


    Notable changes:

    • https://github.com/graphql-go/graphql/pull/123/commits/58f2928b94007b502f882eee4a9a1f82dd118603 [RFC] Proposed change to directive location introspection
    • https://github.com/graphql-go/graphql/pull/123/commits/2322d258313c9307a838ae7fe1d19e70f57937a1 [RFC] Directives in schema language
      • ❗️Breaking Changes: graphql.NewDirective(*graphql.Directive) => graphql.NewDirective(graphql.DirectiveConfig)
      • Affects those that defined custom directives.
    • https://github.com/graphql-go/graphql/pull/123/commits/03b92b0230f165ff27078db28aceea8c1cbc2432 Move getTypeOf to execute.js and rename to defaultResolveTypeFn to mirror defaultResolveFn
      • ❗️Breaking Changes: removed ObjectType(interface{}, ResolveInfo) *Object from Abstract interface, Union and Interface structs and moved to executor
      • Affects those that directly retrieved the ObjectType of an Abstract type (Union / Interface)
    • https://github.com/graphql-go/graphql/pull/123/commits/79f48da704036914912ccfbf60e1aba6d5714ad1 Add GraphQLSchema types field
      • ❗️Breaking Changes:
      • This introduces a breaking change to the Type System API. Now, any individual Interface type does not have the required information to answer GetPossibleTypes or IsPossibleType without knowing the other types in the Schema. These methods were moved to the Schema API, accepting the abstract type as the first parameter.
      • This also introduces a breaking change to the type comparator functions: IsTypeSubTypeOf and DoTypesOverlap which now require a Schema as a first argument.
    • https://github.com/graphql-go/graphql/pull/123/commits/1e33c35ba9684a3ca02bf0de8b24688636cd3295 [RFC] Add explicit context arg to graphql execution
      • ❗️Breaking Changes
      • Removed Schema from ResolveParams, already available in ResolveParams.Info
      • IsTypeOfFn and ResolveTypeFn params are now struct, similar to FieldResolveFn
      • context is now available for resolving types in IsTypeOfFn and ResolveTypeFn, similar to FieldResolveFn
    • https://github.com/graphql-go/graphql/pull/123/commits/a241e1cac73928a834a7691328c283e413b41661 RFC: Return type overlap validation
    • https://github.com/graphql-go/graphql/pull/123/commits/e23ac77f2b1e34dfeff02469edca600cb54a3b7e Add Schema Definition to IDL.

    Changes to public/exported vars / func

    | Previous | New | Risk | | --- | --- | --- | | graphql.NewDirective(*graphql.Directive) | graphql.NewDirective(graphql.DirectiveConfig) | Low-Medium | | graphql.Abstract.ObjectType(interface{}, ResolveInfo) *Object | removed | Low-Medium | | graphql.Union.ObjectType(interface{}, ResolveInfo) *Object | removed | Low-Medium | | graphql.Interface.ObjectType(interface{}, ResolveInfo) *Object | removed | Low-Medium | | graphql.IsTypeOfFn(interface{}, ResolveInfo) | graphql.IsTypeOfFn(IsTypeOfParams) | High | | graphql.ResolveTypeFn(interface{}, ResolveInfo) | graphql.ResolveTypeFn(ResolveTypeParams) | High | | graphql.ResolveParams.Schema | removed, already available in graphql.ResolveInfo | Low-Medium |

    Source code(tar.gz)
    Source code(zip)
  • v0.4.18(May 31, 2016)

    This release brings up graphql-go on par with graphql-js v0.4.18

    Notable changes:

    • Move the extension definition out of type definition
    • [RFC] Type condition optional on inline fragments.
      • Implements https://github.com/facebook/graphql/pull/100
    • [RFC] Make operation name optional.
      • Implements https://github.com/facebook/graphql/pull/99
    • Spec compliant Int sizing
      • graphql.Int now enforces strict compliance to the spec.
      • int and uint that exceeds 2^32 will be considered as invalid graphql.Int
      • Added/updated scalars_serialization_test.go to reflect the changes
    • Experimental: customisable validation
      • Changed function signature for graphql.NewTypeInfo() to accept a struct.
      • Allows the possibility to remove the experimental FieldDefFn params

    Changes to public/exported vars / func

    | Previous | New | Risk | | --- | --- | --- | | graphql.NAME_REGEXP | graphql.NameRegExp | Low | | graphql.CollectFieldsParam.OperationType | graphql.CollectFieldsParam.RuntimeType | Low | | graphql.GetVisitFn(*visitorOptions, bool, string) | graphql.GetVisitFn(*visitorOptions, string, bool) | Low | | graphql.NewTypeInfo(*Schema) | graphql.NewTypeInfo(*TypeInfoConfig) | Low |

    Source code(tar.gz)
    Source code(zip)
Owner
null
GraphQL implementation for click house in Go.

clickhouse-graphql-go GraphQL implementation for clickhouse in Go. This package stores real time streaming websocket data in clickhouse and uses Graph

Rakesh R 10 Sep 14, 2022
Convert Golang Struct To GraphQL Object On The Fly

Straf Convert Golang Struct To GraphQL Object On The Fly Easily Create GraphQL Schemas Example Converting struct to GraphQL Object type UserExtra stru

Roshan Mehta 33 Aug 31, 2022
Tools to write high performance GraphQL applications using Go/Golang.

graphql-go-tools Sponsors WunderGraph Are you looking for a GraphQL e2e data fetching solution? Supports frameworks like NextJS, type safety with gene

Jens Neuse 391 Sep 23, 2022
A GraphQL complete example using Golang And PostgreSQL

GraphQL with Golang A GraphQL complete example using Golang & PostgreSQL Installation Install the dependencies go get github.com/graphql-go/graphql go

Santo Shakil 2 Aug 25, 2022
A collection of Go packages for creating robust GraphQL APIs

api-fu api-fu (noun) (informal) Mastery of APIs. ?? Packages The top level apifu package is an opinionated library that aims to make it as easy as pos

Chris 43 Jul 1, 2022
graphql parser + utilities

graphql utilities for dealing with GraphQL queries in Go. This package focuses on actually creating GraphQL servers and expects you to describe your s

Travis Cline 56 Aug 31, 2022
GraphQL server with a focus on ease of use

graphql-go The goal of this project is to provide full support of the GraphQL draft specification with a set of idiomatic, easy to use Go packages. Wh

null 4.2k Sep 19, 2022
GraphQL server with a focus on ease of use

graphql-go The goal of this project is to provide full support of the GraphQL draft specification with a set of idiomatic, easy to use Go packages. Wh

null 4.2k Sep 23, 2022
GQLEngine is the best productive solution for implementing a GraphQL server 🚀

GQLEngine is the best productive solution for implementing a graphql server for highest formance examples starwars: https://github.com/gqlengine/starw

null 88 Apr 24, 2022
⚡️ A Go framework for rapidly building powerful graphql services

Thunder is a Go framework for rapidly building powerful graphql servers. Thunder has support for schemas automatically generated from Go types, live q

null 1.5k Sep 23, 2022
go generate based graphql server library

gqlgen What is gqlgen? gqlgen is a Go library for building GraphQL servers without any fuss. gqlgen is based on a Schema first approach — You get to D

99designs 8.1k Sep 26, 2022
gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.

gqlanalysis gqlanalysis defines the interface between a modular static analysis for GraphQL in Go. gqlanalysis is inspired by go/analysis. gqlanalysis

null 36 Sep 9, 2022
Go monolith with embedded microservices including GRPC,REST,GraphQL and The Clean Architecture.

GoArcc - Go monolith with embedded microservices including GRPC,REST, graphQL and The Clean Architecture. Description When you start writing a Go proj

Deqode 80 Sep 10, 2022
GraphQL parser comparison in different languages

graphql-parser-bench Parsing a schema or document can be a critical part of the application, especially if you have to care about latency. This is the

Dustin Deus 22 Jul 10, 2022
A simple Go, GraphQL, and PostgreSQL starter template

Simple Go/GraphQL/PostgreSQL template Purpose Have a good starting point for any project that needs a graphql, go, and postgres backend. It's a very l

Chris 0 Jan 8, 2022
This app is an attempt towards using go lang with graphql data fetch in react front end.

go_movies _A React js + GraphQL supported with backend in GoLang. This app is an attempt towards using go lang with graphql data fetch in react front

Abhijit Mukherjee 0 Dec 7, 2021
proof-of-concept minimal GraphQL service for LTV

LTV GraphQL Proof-of-Concept This is a barebones proof-of-concept of a possible GraphQL implementation that interacts with Core. It includes a few ver

Nick Kelley 1 Jan 4, 2022
Learn GraphQL with THE [email protected] SHINY COLORS.

faaaar Learn GraphQL with THE [email protected] SHINY COLORS. Getting Started The following is a simple example which get information about 20-year-old idols

tokizo 0 Jul 18, 2022
A simple (yet effective) GraphQL to HTTP / REST router

ReGraphQL A simple (yet effective) GraphQL to REST / HTTP router. ReGraphQL helps you expose your GraphQL queries / mutations as REST / HTTP endpoints

Ezequiel Aceto 4 May 26, 2022