client

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 9 Imported by: 9

README

This client is used internally for testing. I wanted a simple graphql client sent user specified queries.

You might want to look at:

Documentation

Overview

client is used internally for testing. See readme for alternatives

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 for graphql requests

func New

func New(url string, client ...*http.Client) *Client

New creates a graphql client

func (*Client) MustPost

func (p *Client) MustPost(query string, response interface{}, options ...Option)

func (*Client) Post

func (p *Client) Post(query string, response interface{}, options ...Option) (resperr error)

func (*Client) RawPost added in v0.6.0

func (p *Client) RawPost(query string, options ...Option) (*ResponseData, error)

func (*Client) Websocket

func (p *Client) Websocket(query string, options ...Option) *Subscription

func (*Client) WebsocketWithPayload added in v0.6.0

func (p *Client) WebsocketWithPayload(query string, initPayload map[string]interface{}, options ...Option) *Subscription

type Option

type Option func(r *Request)

func Operation

func Operation(name string) Option

func Var

func Var(name string, value interface{}) Option

type RawJsonError

type RawJsonError struct {
	json.RawMessage
}

func (RawJsonError) Error

func (r RawJsonError) Error() string

type Request

type Request struct {
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables,omitempty"`
	OperationName string                 `json:"operationName,omitempty"`
}

type ResponseData added in v0.6.0

type ResponseData struct {
	Data       interface{}
	Errors     json.RawMessage
	Extensions map[string]interface{}
}

type Subscription

type Subscription struct {
	Close func() error
	Next  func(response interface{}) error
}

Jump to

Keyboard shortcuts

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