Documentation ¶
Overview ¶
Package graphql provides a low level GraphQL client.
ctx := context.Background() ctx = graphql.NewContext(ctx, "https://machinebox.io/graphql") r := graphql.NewRequest(` query ($key: String!) { items (id:$key) { field1 field2 field3 } } `) r.Var("key", "value") var respData ResponseStruct if err := r.Run(ctx, &respData); err != nil { log.Fatalln(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsGraphQLErr ¶
IsGraphQLErr gets whether the error is a remote GraphQL server error or not.
func NewContext ¶
NewContext makes a new context.Context that enables requests.
Types ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a GraphQL request.
func NewRequest ¶
NewRequest makes a new Request with the specified string.
func (*Request) Run ¶
Run executes the query and unmarshals the response from the data field into the response object. Pass in a nil response object to skip response parsing. If the request fails or the server returns an error, the first error will be returned. Use IsGraphQLErr to determine which it was.
Click to show internal directories.
Click to hide internal directories.