graphqlutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 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 Errors 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 Errors added in v0.11.0

type Errors []*Error

Errors is a list of GraphQL errors.

func (Errors) Error added in v0.11.0

func (e Errors) Error() string

func (Errors) Unwrap added in v0.11.0

func (e Errors) Unwrap() []error

Jump to

Keyboard shortcuts

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