githubapi

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrGraphQLNotFound = errors.New("GraphQL resource not found")

ErrGraphQLNotFound is an error used to test when GitHub GraphQL query returns a single error with the type "NOT_FOUND".

It should be used with errors.Is.

Functions

func BatchQuery

func BatchQuery[T any](ctx context.Context, c *Client, queries map[string]string, vars map[string]any) (map[string]T, error)

BatchQuery can be used to batch a set of requests together to GitHub's GraphQL API.

func ErrorResponseStatusCode

func ErrorResponseStatusCode(err error) int

ErrorResponseStatusCode will unwrap a github.ErrorResponse and return the status code inside.

If the error is nil, or not an ErrorResponse it will return a status code of 0.

func NewRetryRoundTripper

func NewRetryRoundTripper(rt http.RoundTripper, logger *zap.Logger) http.RoundTripper

Types

type Client

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

Client provides simple access to GitHub's REST and GraphQL APIs.

func NewClient

func NewClient(client *http.Client) *Client

NewClient creates a new instances of Client.

func (*Client) GraphQL

func (c *Client) GraphQL() *githubv4.Client

GraphQL returns a client for communicating with GitHub's GraphQL API.

func (*Client) Rest

func (c *Client) Rest() *github.Client

Rest returns a client for communicating with GitHub's REST API.

type GraphQLError

type GraphQLError struct {
	Message   string
	Type      string // GitHub specific GraphQL error field
	Locations []struct {
		Line   int
		Column int
	}
}

GraphQLError stores the error result from a GitHub GraphQL query.

type GraphQLErrors

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

GraphQLErrors wraps all the errors returned by a GraphQL response.

func (*GraphQLErrors) Error

func (e *GraphQLErrors) Error() string

Error implements error interface.

func (*GraphQLErrors) Errors

func (e *GraphQLErrors) Errors() []GraphQLError

Errors returns a slice with each Error returned by the GraphQL API.

func (*GraphQLErrors) HasType

func (e *GraphQLErrors) HasType(t string) bool

HasType returns true if one of the errors matches the supplied type.

func (*GraphQLErrors) Is

func (e *GraphQLErrors) Is(target error) bool

Is implements the errors.Is interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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