gqlclient

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforeFunc

type BeforeFunc func(req *http.Request) error

BeforeFunc modifies the request before it is sent

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client a graphql client

func NewClient

func NewClient(opts *Options) (client *Client, err error)

NewClient creates a new client

func (*Client) Request

func (c *Client) Request(request Request) (rsp *Response, err error)

Request performs a request

type Options

type Options struct {
	URL            string
	Before         []BeforeFunc
	Insecure       bool
	RequestTimeout time.Duration
	HTTPClient     *http.Client
}

Options client options

type Request

type Request struct {
	Query         string
	OperationName string
	Variables     map[string]interface{}
}

Request interface to a request object so you can bring your own

func (*Request) GetOperationName

func (r *Request) GetOperationName() string

GetOperationName gets the operation name

func (*Request) GetQuery

func (r *Request) GetQuery() string

GetQuery gets the query

func (*Request) GetVariables

func (r *Request) GetVariables() map[string]interface{}

GetVariables gets the variables

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response response object

func (*Response) Data

func (c *Response) Data() interface{}

Data returns the data

func (*Response) Decode

func (c *Response) Decode(out interface{}) (err error)

Decode decodes the result into the provided interface

func (*Response) Errors

func (c *Response) Errors() gqlerrors.FormattedErrors

Errors returns the errors

func (*Response) FirstError

func (c *Response) FirstError() *gqlerrors.FormattedError

FirstError returns the first error

func (*Response) HTTPRequest

func (c *Response) HTTPRequest() *http.Request

HTTPRequest returns the http request

func (*Response) HTTPResponse

func (c *Response) HTTPResponse() *http.Response

HTTPResponse returns the http response

func (*Response) HasErrors

func (c *Response) HasErrors() bool

HasErrors returns true if errors are present

func (*Response) RawResult

func (c *Response) RawResult() []byte

RawResult returns the raw result body

Jump to

Keyboard shortcuts

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