- Notifications
You must be signed in to change notification settings - Fork846
An implementation of GraphQL for Go / Golang
License
graphql-go/graphql
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An implementation of GraphQL in Go. Follows the official reference implementationgraphql-js
.
Supports: queries, mutations & subscriptions.
godoc:https://pkg.go.dev/github.com/graphql-go/graphql
Friendly reminder links are available in case you would like to contribute back into our commitment with Go and open-source.
Author | PayPal Link |
---|---|
Hafiz Ismail | Not available yet. |
Chris Ramón | https://www.paypal.com/donate/?hosted_button_id=WHUQQYEMTRQBJ |
To install the library, run:
go get github.com/graphql-go/graphql
The following is a simple example which defines a schema with a singlehello
string-type field and aResolve
method which returns the stringworld
. A GraphQL query is performed against this schema with the resulting output printed in JSON format.
package mainimport ("encoding/json""fmt""log""github.com/graphql-go/graphql")funcmain() {// Schemafields:= 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)iferr!=nil {log.Fatalf("failed to create new schema, error: %v",err)}// Queryquery:=`{hello}`params:= graphql.Params{Schema:schema,RequestString:query}r:=graphql.Do(params)iflen(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 theexamples/ directory andgraphql_test.go.
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. |
About
An implementation of GraphQL for Go / Golang
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.