gql

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 7 Imported by: 4

README

GQL

A simple GraphQL client.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultOptions are the default set of ClientOptions for a Client
	DefaultOptions = &ClientOptions{
		HTTP: http.DefaultClient,
	}
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Endpoint string
	Options  *ClientOptions
}

Client is a client aimed at a specific GraphQL endpoint

func NewClient

func NewClient(endpoint string, options *ClientOptions) *Client

NewClient returns a new Client for making GraphQL requests

func (*Client) Run

func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error

Run runs a given Request using the Client

type ClientOptions

type ClientOptions struct {
	HTTP *http.Client
}

ClientOptions are options that can be set for a Client

type Error

type Error struct {
	Message string `json:"message"`
}

Error is an individual GraphQL error

func (Error) Error

func (e Error) Error() string

Error fills the error interface

type Errors

type Errors []Error

Errors is a collection of GraphQL errors

func (Errors) Error

func (e Errors) Error() string

Error fills the error interface

type Request

type Request struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables"`
	Header    http.Header            `json:"-"`
}

Request is a GraphQL request

func NewRequest

func NewRequest(query string) *Request

NewRequest returns a new Request

type Response

type Response struct {
	Data   interface{} `json:"data"`
	Errors Errors      `json:"errors"`
}

Response is the response to a GraphQL Request

Jump to

Keyboard shortcuts

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