apiclient

package
v0.0.0-...-27254ba Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient

type ApiClient struct {
	Endpoint string

	Header http.Header
	// contains filtered or unexported fields
}

func NewApiClient

func NewApiClient(endpoint string, httpClient *http.Client) *ApiClient

func (*ApiClient) CreateGraphQLPayload

func (api *ApiClient) CreateGraphQLPayload(query string, variables map[string]interface{}) (*bytes.Buffer, error)

func (*ApiClient) Post

func (api *ApiClient) Post(ctx context.Context, payload interface{}, modify *func(r *http.Request) *http.Request) (*http.Response, error)

func (*ApiClient) SendGraphQLQuery

func (api *ApiClient) SendGraphQLQuery(ctx context.Context, query string, variables map[string]interface{}) (*ApiResponse, error)

type ApiResponse

type ApiResponse struct {
	Data   *json.RawMessage `json:"data"`
	Errors GQLApiErrors     `json:"errors"`
	// contains filtered or unexported fields
}

func (*ApiResponse) DecodeIntoInterface

func (r *ApiResponse) DecodeIntoInterface() (target interface{}, err error)

func (*ApiResponse) GetBody

func (r *ApiResponse) GetBody() []byte

func (*ApiResponse) GetResponse

func (r *ApiResponse) GetResponse() *http.Response

func (*ApiResponse) GetStringBody

func (r *ApiResponse) GetStringBody() string

func (*ApiResponse) GetStringReader

func (r *ApiResponse) GetStringReader() *strings.Reader

type ApiResponseParsed

type ApiResponseParsed struct {
	Data   map[string]interface{} `json:"data"`
	Errors GQLApiErrors           `json:"errors"`
}

type GQLApiErrors

type GQLApiErrors []struct {
	Message   string
	Locations []struct {
		Line   int
		Column int
	}
}

GQLApiErrors represents the "errors" array in a response from a GraphQL server. If returned via error interface, the slice is expected to contain at least 1 element.

Specification: https://facebook.github.io/graphql/#sec-Errors.

func (GQLApiErrors) Error

func (e GQLApiErrors) Error() string

Error implements error interface for GQLApiErrors.

type GraphQLOperation

type GraphQLOperation string
const (
	GraphQLQuery    GraphQLOperation = "query"
	GraphQLMutation GraphQLOperation = "mutation"
)

Jump to

Keyboard shortcuts

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