graphqlerrors

package
v2.0.0-rc.104 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorPath

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

func (*ErrorPath) Len

func (e *ErrorPath) Len() int

func (*ErrorPath) MarshalJSON

func (e *ErrorPath) MarshalJSON() ([]byte, error)

func (*ErrorPath) String

func (e *ErrorPath) String() string

type Errors

type Errors interface {
	error
	WriteResponse(writer io.Writer) (n int, err error)
	Count() int
	ErrorByIndex(i int) error
}

type RequestError

type RequestError struct {
	Message   string                     `json:"message"`
	Locations []operationreport.Location `json:"locations,omitempty"`
	Path      ErrorPath                  `json:"path"`
}

func (RequestError) Error

func (o RequestError) Error() string

func (RequestError) MarshalJSON

func (o RequestError) MarshalJSON() ([]byte, error)

type RequestErrors

type RequestErrors []RequestError

func RequestErrorsFromError

func RequestErrorsFromError(err error) RequestErrors

func RequestErrorsFromOperationReport

func RequestErrorsFromOperationReport(report operationreport.Report) (errors RequestErrors)

func (RequestErrors) Count

func (o RequestErrors) Count() int

func (RequestErrors) Error

func (o RequestErrors) Error() string

func (RequestErrors) ErrorByIndex

func (o RequestErrors) ErrorByIndex(i int) error

func (RequestErrors) WriteResponse

func (o RequestErrors) WriteResponse(writer io.Writer) (n int, err error)

WriteResponse writes the given request errors to the http.ResponseWriter. It should only be used to write errors that are happening before the execution of the query e.g. validation errors.

type Response

type Response struct {
	Errors Errors `json:"errors,omitempty"`
	// data: null will never be included in the response because this struct should be used for errors that happening before execution
	// This behaviour is compliant with the spec https://spec.graphql.org/draft/#sec-Data
	Data any `json:"data,omitempty"`
}

Response is the GraphQL response object It should only be used to write errors that are happening before the execution of the query e.g. validation errors.

func (Response) Marshal

func (r Response) Marshal() ([]byte, error)

Jump to

Keyboard shortcuts

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