Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An implementation of GraphQL for Go / Golang

License

NotificationsYou must be signed in to change notification settings

graphql-go/graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Supports: queries, mutations & subscriptions.

Documentation

godoc:https://pkg.go.dev/github.com/graphql-go/graphql

Contribute Back

Friendly reminder links are available in case you would like to contribute back into our commitment with Go and open-source.

AuthorPayPal Link
Hafiz IsmailNot available yet.
Chris Ramónhttps://www.paypal.com/donate/?hosted_button_id=WHUQQYEMTRQBJ

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

Third Party Libraries

NameAuthorDescription
graphql-go-handlerHafiz IsmailMiddleware to handle GraphQL queries through HTTP requests.
graphql-relay-goHafiz IsmailLib to construct a graphql-go server supporting react-relay.
golang-relay-starter-kitHafiz IsmailBarebones starting point for a Relay application with Golang GraphQL server.
dataloaderNick RandallDataLoader implementation in Go.

Blog Posts

About

An implementation of GraphQL for Go / Golang

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp