graphql

package
v0.0.0-...-c52f24a Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var False = lit(falseLit)
View Source
var Null = lit(nullLit)
View Source
var True = lit(trueLit)

Functions

func AddError

func AddError(ctx context.Context, err error)

AddError is a convenience method for adding an error to the current response

func AddErrorf

func AddErrorf(ctx context.Context, format string, args ...interface{})

AddErrorf is a convenience method for adding an error to the current response

func DefaultRecover

func DefaultRecover(ctx context.Context, err interface{}) error

func DefaultRequestMiddleware

func DefaultRequestMiddleware(ctx context.Context, next func(ctx context.Context) []byte) []byte

func DefaultResolverMiddleware

func DefaultResolverMiddleware(ctx context.Context, next Resolver) (res interface{}, err error)

func OneShot

func OneShot(resp *Response) func() *Response

func UnmarshalBoolean

func UnmarshalBoolean(v interface{}) (bool, error)

func UnmarshalFloat

func UnmarshalFloat(v interface{}) (float64, error)

func UnmarshalID

func UnmarshalID(v interface{}) (string, error)

func UnmarshalInt

func UnmarshalInt(v interface{}) (int, error)

func UnmarshalMap

func UnmarshalMap(v interface{}) (map[string]interface{}, error)

func UnmarshalString

func UnmarshalString(v interface{}) (string, error)

func UnmarshalTime

func UnmarshalTime(v interface{}) (time.Time, error)

func WithRequestContext

func WithRequestContext(ctx context.Context, rc *RequestContext) context.Context

func WithResolverContext

func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Context

Types

type Array

type Array []Marshaler

func (Array) MarshalGQL

func (a Array) MarshalGQL(writer io.Writer)

type CollectedField

type CollectedField struct {
	Alias      string
	Name       string
	Args       map[string]interface{}
	Selections []query.Selection
}

func CollectFields

func CollectFields(doc *query.Document, selSet []query.Selection, satisfies []string, variables map[string]interface{}) []CollectedField

func CollectFieldsCtx

func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField

This is just a convenient wrapper method for CollectFields

type Error

type Error struct {
	Message    string                 `json:"message"`
	Path       []interface{}          `json:"path,omitempty"`
	Locations  []ErrorLocation        `json:"locations,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

Error is the standard graphql error type described in https://facebook.github.io/graphql/draft/#sec-Errors

func DefaultErrorPresenter

func DefaultErrorPresenter(ctx context.Context, err error) *Error

func (*Error) Error

func (e *Error) Error() string

type ErrorLocation

type ErrorLocation struct {
	Line   int `json:"line,omitempty"`
	Column int `json:"column,omitempty"`
}

type ErrorPresenterFunc

type ErrorPresenterFunc func(context.Context, error) *Error

type ExecutableSchema

type ExecutableSchema interface {
	Schema() *schema.Schema

	Query(ctx context.Context, op *query.Operation) *Response
	Mutation(ctx context.Context, op *query.Operation) *Response
	Subscription(ctx context.Context, op *query.Operation) func() *Response
}

type ExtendedError

type ExtendedError interface {
	Extensions() map[string]interface{}
}

type Marshaler

type Marshaler interface {
	MarshalGQL(w io.Writer)
}

func Defer

func Defer(f func() Marshaler) Marshaler

Defer will begin executing the given function and immediately return a result that will block until the function completes

func MarshalBoolean

func MarshalBoolean(b bool) Marshaler

func MarshalFloat

func MarshalFloat(f float64) Marshaler

func MarshalID

func MarshalID(s string) Marshaler

func MarshalInt

func MarshalInt(i int) Marshaler

func MarshalMap

func MarshalMap(val map[string]interface{}) Marshaler

func MarshalString

func MarshalString(s string) Marshaler

func MarshalTime

func MarshalTime(t time.Time) Marshaler

type OrderedMap

type OrderedMap struct {
	Keys   []string
	Values []Marshaler
}

func NewOrderedMap

func NewOrderedMap(len int) *OrderedMap

func (*OrderedMap) Add

func (m *OrderedMap) Add(key string, value Marshaler)

func (*OrderedMap) MarshalGQL

func (m *OrderedMap) MarshalGQL(writer io.Writer)

type RecoverFunc

type RecoverFunc func(ctx context.Context, err interface{}) (userMessage error)

type RequestContext

type RequestContext struct {
	RawQuery  string
	Variables map[string]interface{}
	Doc       *query.Document
	// ErrorPresenter will be used to generate the error
	// message from errors given to Error().
	ErrorPresenter     ErrorPresenterFunc
	Recover            RecoverFunc
	ResolverMiddleware ResolverMiddleware
	RequestMiddleware  RequestMiddleware

	Errors []*Error
	// contains filtered or unexported fields
}

func GetRequestContext

func GetRequestContext(ctx context.Context) *RequestContext

func NewRequestContext

func NewRequestContext(doc *query.Document, query string, variables map[string]interface{}) *RequestContext

func (*RequestContext) Error

func (c *RequestContext) Error(ctx context.Context, err error)

Error sends an error to the client, passing it through the formatter.

func (*RequestContext) Errorf

func (c *RequestContext) Errorf(ctx context.Context, format string, args ...interface{})

Errorf sends an error string to the client, passing it through the formatter.

type RequestMiddleware

type RequestMiddleware func(ctx context.Context, next func(ctx context.Context) []byte) []byte

type Resolver

type Resolver func(ctx context.Context) (res interface{}, err error)

type ResolverContext

type ResolverContext struct {
	// The name of the type this field belongs to
	Object string
	// These are the args after processing, they can be mutated in middleware to change what the resolver will get.
	Args map[string]interface{}
	// The raw field
	Field CollectedField
	// The path of fields to get to this resolver
	Path []interface{}
}

func GetResolverContext

func GetResolverContext(ctx context.Context) *ResolverContext

func (*ResolverContext) Pop

func (r *ResolverContext) Pop()

func (*ResolverContext) PushField

func (r *ResolverContext) PushField(alias string)

func (*ResolverContext) PushIndex

func (r *ResolverContext) PushIndex(index int)

type ResolverMiddleware

type ResolverMiddleware func(ctx context.Context, next Resolver) (res interface{}, err error)

type Response

type Response struct {
	Data   json.RawMessage `json:"data"`
	Errors []*Error        `json:"errors,omitempty"`
}

func ErrorResponse

func ErrorResponse(ctx context.Context, messagef string, args ...interface{}) *Response

type Unmarshaler

type Unmarshaler interface {
	UnmarshalGQL(v interface{}) error
}

type WriterFunc

type WriterFunc func(writer io.Writer)

func (WriterFunc) MarshalGQL

func (f WriterFunc) MarshalGQL(w io.Writer)

Jump to

Keyboard shortcuts

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