Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
graphql
✓ github.com/graphql-go/graphql
Executes a simple GraphQL query
package main
import (
"fmt"
"github.com/graphql-go/graphql"
)
func main() {
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, _ := graphql.NewSchema(schemaConfig)
params := graphql.Params{Schema: schema, RequestString: "{ hello }"}
result := graphql.Do(params)
fmt.Printf("%+v", result)
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.8.1latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.