graphqlutil

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package graphqlutil provides utilities for working with GraphQL.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("not found")
	ErrForbidden = errors.New("forbidden")
)

Common errors that may be returned by GraphQL APIs. These may be matched with errors.Is.

Functions

func WrapTransport

func WrapTransport(t http.RoundTripper) http.RoundTripper

WrapTransport wraps an HTTP transport with knowledge of GraphQL errors.

The transport will now return errors that may be cast to ErrorList or Error with errors.As.

Types

type Error

type Error struct {
	Message string `json:"message"`
	Path    []any  `json:"path"`
	Type    string `json:"type"`
}

Error is a single GraphQL error. A single response may contain multiple errors.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

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

Is reports whether this error matches the target error. Use errors.Is to match against this error.

type ErrorList

type ErrorList []*Error

ErrorList is a list of GraphQL errors.

func (ErrorList) Error

func (e ErrorList) Error() string

func (ErrorList) Unwrap

func (e ErrorList) Unwrap() []error

Jump to

Keyboard shortcuts

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