resolvers

package
v0.0.0-...-f420c12 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: BSD-2-Clause Imports: 13 Imported by: 5

Documentation

Overview

Most of this file was reused from the ecoding/json package, since we want to use the same json encoding.

Most of this file was reused from the ecoding/json package, since we want to use the same json encoding.

Index

Constants

View Source
const FieldResolver = fieldResolver(0)
View Source
const MapResolver = mapResolver(0)
View Source
const MetadataResolver = metadataResolver(0)
View Source
const MethodResolver = methodResolver(0)

Variables

View Source
var NilResolver = nilResolver(0)

Functions

func Dereference

func Dereference(value reflect.Value) reflect.Value

func TryCastFunction

func TryCastFunction(value reflect.Value, toType string) (v reflect.Value, ok bool)

Types

type Cache

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

func (*Cache) GetOrElseUpdate

func (cache *Cache) GetOrElseUpdate(key interface{}, create func() interface{}) (x interface{})

type DirectiveResolver

type DirectiveResolver struct {
	Directive string
	Create    func(request *ResolveRequest, next Resolution, args map[string]interface{}) Resolution
}

/////////////////////////////////////////////////////////////////////

DirectiveResolver gets applied to fields or types that have a given directive

/////////////////////////////////////////////////////////////////////

func (DirectiveResolver) Resolve

func (factory DirectiveResolver) Resolve(request *ResolveRequest, next Resolution) Resolution

type ExecutionContext

type ExecutionContext interface {
	GetRoot() interface{}
	FireSubscriptionEvent(value reflect.Value, err error)
	FireSubscriptionClose()
	GetSchema() *schema.Schema
	GetContext() context.Context
	GetLimiter() *chan byte
	HandlePanic(selectionPath []string) error
	GetQuery() string
	GetDocument() *schema.QueryDocument
	GetOperation() *schema.Operation
	GetVars() map[string]interface{}
}

type Func

type Func func(request *ResolveRequest, next Resolution) Resolution

func (Func) Resolve

func (f Func) Resolve(request *ResolveRequest, next Resolution) Resolution

type RawMessage

type RawMessage json.RawMessage

When RawMessage is the result of a Resolution, for a field, no sub field resolution performed.

type Resolution

type Resolution func() (reflect.Value, error)

type ResolveRequest

type ResolveRequest struct {
	Context          context.Context
	ExecutionContext ExecutionContext
	ParentResolve    *ResolveRequest
	SelectionPath    func() []string
	ParentType       schema.Type
	Parent           reflect.Value
	Field            *schema.Field
	Args             map[string]interface{}
	Selection        *schema.FieldSelection
}

func (*ResolveRequest) RunAsync

func (this *ResolveRequest) RunAsync(resolver Resolution) Resolution

type Resolver

type Resolver interface {
	// Resolve allows you to inspect a ResolveRequest to see if your resolver can resolve it.
	// If you can resolve it, return a new Resolution that computes the value of the field.
	// If you don't know how to resolve that request, return next.
	//
	// The next variable hold the Resolution of the previous resolver, this allows your resolver
	// to filter it's results.  next may be nil if no resolution has been found yet.
	Resolve(request *ResolveRequest, next Resolution) Resolution
}

func DynamicResolverFactory

func DynamicResolverFactory() Resolver

func MapValue

func MapValue(mapper func(value reflect.Value) reflect.Value) Resolver

MapValue allows you to convert map a resolved result to something new.

func Sniff

func Sniff(sniffer func(request *ResolveRequest, next Resolution)) Resolver

Sniff allows you see resolution requests, but does not impact them

type ResolverList

type ResolverList []Resolver

/////////////////////////////////////////////////////////////////////

ResolverFactoryList uses a list of other resolvers to resolve requests. Last resolver wins.

/////////////////////////////////////////////////////////////////////

func List

func List(factories ...Resolver) *ResolverList

func (*ResolverList) Add

func (this *ResolverList) Add(factory Resolver)

func (*ResolverList) Resolve

func (this *ResolverList) Resolve(request *ResolveRequest, next Resolution) Resolution

type TypeAndFieldKey

type TypeAndFieldKey struct {
	Type  string
	Field string
}

type TypeAndFieldResolver

type TypeAndFieldResolver map[TypeAndFieldKey]Func

func (TypeAndFieldResolver) Resolve

func (r TypeAndFieldResolver) Resolve(request *ResolveRequest, next Resolution) Resolution

func (TypeAndFieldResolver) Set

func (r TypeAndFieldResolver) Set(typeName string, field string, f Func)

type TypeResolver

type TypeResolver map[string]Resolver

func (TypeResolver) Resolve

func (this TypeResolver) Resolve(request *ResolveRequest, next Resolution) Resolution

func (TypeResolver) Set

func (this TypeResolver) Set(typeName string, factory Resolver)

type ValueWithContext

type ValueWithContext struct {
	Value   reflect.Value
	Context context.Context
}

Jump to

Keyboard shortcuts

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