client

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = NewClient()

A simple client with no default URL.

Functions

This section is empty.

Types

type GraphQLClient

type GraphQLClient struct {
	// The underlying http client to use.
	// Use this to configure settings like timeouts.
	HttpClient *http.Client

	// The GraphQL endpoint to make requests to.
	// This can be left as nil if you want to configure it on a per-request level.
	Url *url.URL

	// Shared HTTP headers to send with every request.
	Header http.Header
}

A simple GraphQL client with configurable defaults.

func NewClient added in v0.2.0

func NewClient() *GraphQLClient

Initialize a new GraphQLClient.

func (*GraphQLClient) Do

func (client *GraphQLClient) Do(request *GraphQLRequest, unmarshal interface{}) error

Perform a GraphQL request and unmarshal the response to the provided type.

func (*GraphQLClient) SetUrl added in v0.2.0

func (client *GraphQLClient) SetUrl(baseUrl string) error

Set the endpoint URL from a string.

type GraphQLError

type GraphQLError struct {
	Message    string                 `json:"message"`
	Locations  []GraphQLErrorLocation `json:"locations"`
	Path       []interface{}          `json:"path"`
	Extensions map[string]interface{} `json:"extensions"`
}

func (GraphQLError) Error

func (err GraphQLError) Error() string

type GraphQLErrorList

type GraphQLErrorList []GraphQLError

func (GraphQLErrorList) Error

func (errs GraphQLErrorList) Error() string

type GraphQLErrorLocation

type GraphQLErrorLocation struct {
	Line   int32 `json:"line"`
	Column int32 `json:"column"`
}

type GraphQLRequest

type GraphQLRequest struct {
	// The URL to request from.
	// If a URL was provided to the client, you can leave this empty.
	Url string

	// Headers to include in the request.
	// Headers provided here will override the ones provided in the client.
	Header http.Header

	// The GraphQL query string.
	Query string

	// The input variable type. Should be JSON-marshalable.
	// Minigen automatically generates these types where applicable.
	Variables interface{}

	// If multiple queries are included in the Query string,
	// provide the name of the query to execute.
	OperationName string
}

Input type for GraphQLClient.Do()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL