Documentation
¶
Overview ¶
Package graphql provides client support for executing graphql requests against a host that supports the graphql protocol.
Index ¶
- func WithClient(client *http.Client) func(gql *GraphQL)
- func WithHeader(key string, value string) func(gql *GraphQL)
- func WithLogging(logFunc func(s string)) func(gql *GraphQL)
- func WithVariable(key string, value interface{}) func(m map[string]interface{})
- type GraphQL
- func (g *GraphQL) Execute(ctx context.Context, graphql string, response interface{}, ...) error
- func (g *GraphQL) ExecuteOnEndpoint(ctx context.Context, endpoint string, graphql string, response interface{}, ...) error
- func (g *GraphQL) RawRequest(ctx context.Context, endpoint string, r io.Reader, response interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithClient ¶ added in v1.4.4
WithClient adds a custom client for processing requests. It's recommend to not use the default client and provide your own.
func WithHeader ¶ added in v1.4.4
WithHeader adds a key/value pair to the request header for all calls made to the host. This is for things like authentication or application specific needs. These headers are already included: "Cache-Control": "no-cache", "Content-Type": "application/json", "Accept": "application/json"
func WithLogging ¶ added in v1.6.0
WithLogging acceps a function for capturing raw execution messages for the purpose of application logging.
func WithVariable ¶ added in v1.5.0
WithVariable allows for the submission of variables when executing graphql against the host for queries that supports variable substitution.
Types ¶
type GraphQL ¶
type GraphQL struct {
// contains filtered or unexported fields
}
GraphQL represents a client that can execute graphql and raw requests against a host.
func New ¶
New constructs a GraphQL that can be used to execute graphql and raw requests against the specified url. The url represents a fully qualified URL without the `graphql` endpoint attached. If `/graphql` is provided, it's trimmed off.
func (*GraphQL) Execute ¶ added in v1.6.0
func (g *GraphQL) Execute(ctx context.Context, graphql string, response interface{}, variables ...func(m map[string]interface{})) error
Execute performs a graphql request against the configured host on the url/graphql endpoint.
func (*GraphQL) ExecuteOnEndpoint ¶ added in v1.6.0
func (g *GraphQL) ExecuteOnEndpoint(ctx context.Context, endpoint string, graphql string, response interface{}, variables ...func(m map[string]interface{})) error
ExecuteOnEndpoint performs a graphql request against the configured host on the specified url/endpoint
func (*GraphQL) RawRequest ¶ added in v1.6.0
func (g *GraphQL) RawRequest(ctx context.Context, endpoint string, r io.Reader, response interface{}) error
RawRequest performs the actual execution of a request against the specified url/endpoint. Use this function only when the request doesn't require a graphql document wrapper.