client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorTooManyRequet = errors.New("too many request")

ErrorTooManyRequet is an error representing too many request

Functions

This section is empty.

Types

type Client

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

Client is http client for kibela

func New

func New(ver, team, token string) (*Client, error)

New returns new http client

func Test

func Test(cli Doer) *Client

Test for create test client for using testing only

func (*Client) Do

func (cli *Client) Do(ctx context.Context, pa *Payload) (json.RawMessage, error)

Do GraphQL request

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer is an interface for mocking http client

type Error

type Error struct {
	Message    string          `json:"message"`
	Locations  []ErrorLocation `json:"locations,omitempty"`
	Path       []interface{}   `json:"path,omitempty"` // string or uint
	Extensions ErrorExtensions `json:"extensions"`
}

Error is error type for GraphQL request

type ErrorCode

type ErrorCode string

ErrorCode is for representing error types

const (
	RequestLimitExceeded ErrorCode = "REQUEST_LIMIT_EXCEEDED"
	TokenBudgetExhausted ErrorCode = "TOKEN_BUDGET_EXHAUSTED"
	TeamBudgetExhausted  ErrorCode = "TEAM_BUDGET_EXHAUSTED"
)

ErrorCodes

type ErrorExtensions

type ErrorExtensions struct {
	Code              ErrorCode `json:"code"`
	WaitMilliSecondes uint      `json:"waitMilliseconds,omitempty"`
}

ErrorExtensions is for extra information of errors

type ErrorLocation

type ErrorLocation struct {
	Line   uint `json:"line"`
	Column uint `json:"column"`
}

ErrorLocation is represents error location

type Errors

type Errors []Error

Errors is an error type contained multiple errors

{
  "errors": [
    {
      "message": "Unexpected end of document",
      "extensions": {
        "code": "PARSE_ERROR"
      }
    }
  ]
}

func (Errors) Error

func (e Errors) Error() string

Error is for error type

type Payload

type Payload struct {
	Query     string      `json:"query"`
	Variables interface{} `json:"variables,omitempty"`
}

Payload is GraphQL payload

Jump to

Keyboard shortcuts

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