Documentation ¶
Index ¶
- Constants
- Variables
- func BatchQuery[T any](ctx context.Context, c *Client, queries map[string]string) (map[string]T, error)
- func ErrorResponseStatusCode(err error) int
- func NewRetryRoundTripper(rt http.RoundTripper, logger *zap.Logger) http.RoundTripper
- type Client
- type GitTimestamp
- type GraphQLError
- type GraphQLErrors
Constants ¶
const DefaultGraphQLEndpoint = "https://api.github.com/graphql"
DefaultGraphQLEndpoint is the default URL for the GitHub GraphQL API.
Variables ¶
var ( // 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. ErrGraphQLNotFound = errors.New("GraphQL resource not found") // ErrGraphQLForbidden is an error used to test when GitHub GraphQL query // returns a single error with the type "FORBIDDEN". // // It should be used with errors.Is. ErrGraphQLForbidden = errors.New("GraphQL access forbidden") )
Functions ¶
func BatchQuery ¶
func BatchQuery[T any](ctx context.Context, c *Client, queries map[string]string) (map[string]T, error)
BatchQuery can be used to batch a set of requests together to GitHub's GraphQL API.
The queries must be for objects represented by type T. T should be a struct to work correctly.
func ErrorResponseStatusCode ¶
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.
type GitTimestamp ¶
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.