Documentation
¶
Overview ¶
Package graphql is a GraphQL client with no third party dependencies.
Initial version based on https://github.com/machinebox/graphql
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for interacting with a GraphQL API.
type Error ¶
type Error struct {
// Message contains the error message.
Message string
// Locations contains the locations in the GraphQL document that caused the
// error if the error can be associated to a particular point in the
// requested GraphQL document.
Locations []Location
// Path contains the key path of the response field which experienced the
// error. This allows clients to identify whether a nil result is
// intentional or caused by a runtime error.
Path []interface{}
// Extensions may contain additional fields set by the GraphQL service,
// such as an error code.
Extensions map[string]interface{}
}
An Error contains error information returned by the GraphQL server.
type Errors ¶
type Errors []Error
Errors contains all the errors that were returned by the GraphQL server.
type Location ¶
A Location is a location in the GraphQL query that resulted in an error. The location may be returned as part of an error response.
type Option ¶
type Option func(*Client)
Option are functions that are passed into NewClient to modify the behaviour of the Client.
func ImmediatelyCloseReqBody ¶
func ImmediatelyCloseReqBody() Option
ImmediatelyCloseReqBody will close the req body immediately after each request body is ready
func WithHTTPClient ¶
WithHTTPClient specifies the underlying http.Client to use when making requests.
NewClient(endpoint, WithHTTPClient(specificHTTPClient))
type Request ¶
type Request struct {
// Header represent any request headers that will be set
// when the request is made.
Header http.Header
// contains filtered or unexported fields
}
Request is a GraphQL request.
func NewRequest ¶
func NewRequest(q string, options ...RequestOption) *Request
NewRequest makes a new request with the specified query and options.
type RequestOption ¶
type RequestOption func(*Request)
RequestOption is an option function for a request.
func Header ¶
func Header(key, value string) RequestOption
Header sets the provided key and value as a header on the request.
func Variable ¶
func Variable(key string, value any) RequestOption
Variable sets the provided key and value as a variable on the request.