Documentation
¶
Overview ¶
Package graphql provides support for executing mutations and queries against a database using GraphQL. It was designed specifically for working with [Dgraph](https://dgraph.io/) and has some Dgraph specific support.
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, queryString string, response interface{}, ...) error
- func (g *GraphQL) ExecuteOnEndpoint(ctx context.Context, endpoint string, queryString 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.
func WithHeader ¶ added in v1.4.4
WithHeader adds a key value pair to the header for requests.
func WithLogging ¶ added in v1.6.0
WithLogging acceps a function for logging raw execution messages.
func WithVariable ¶ added in v1.5.0
WithVariable allows for the submission of variables to the query.
Types ¶
type GraphQL ¶
type GraphQL struct {
// contains filtered or unexported fields
}
GraphQL represents a system that can accept a graphql query.
func New ¶
New constructs a GraphQL for use to making queries agains a specified host. The url is the fully qualifying URL without the /graphql path.
func (*GraphQL) Execute ¶ added in v1.6.0
func (g *GraphQL) Execute(ctx context.Context, queryString string, response interface{}, variables ...func(m map[string]interface{})) error
Execute performs a GraphQL query against the configured server on the graphql endpoint from the base URL.
func (*GraphQL) ExecuteOnEndpoint ¶ added in v1.6.0
func (g *GraphQL) ExecuteOnEndpoint(ctx context.Context, endpoint string, queryString string, response interface{}, variables ...func(m map[string]interface{})) error
ExecuteOnEndpoint performs a GraphQL query against the configured server on the specified endpoint from the base URL.