execution

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package execution is a complete GraphQL runtime. It contains a Handler to orchestrate the execution, a Query Planner to generate a Query Plan from an AST as well as the Executor to execute a Query Plan.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgsResolver

type ArgsResolver interface {
	ResolveArgs(args []datasource.Argument, data []byte) ResolvedArgs
}

type BooleanCondition

type BooleanCondition interface {
	Evaluate(ctx Context, data []byte) bool
}

type Context

type Context struct {
	context.Context
	Variables      Variables
	ExtraArguments []datasource.Argument
}

type DataResolvingConfig

type DataResolvingConfig struct {
	PathSelector   datasource.PathSelector
	Transformation Transformation
}

type DataSourceDefinition

type DataSourceDefinition struct {
	// the type name to which the data source is attached
	TypeName []byte
	// the field on the type to which the data source is attached
	FieldName []byte
	// a factory method to return a new planner
	DataSourcePlannerFactory func() datasource.Planner
}

type DataSourceInvocation

type DataSourceInvocation struct {
	Args       []datasource.Argument
	DataSource datasource.DataSource
}

type ErrJSONValueTypeValueIncompatible

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

func (ErrJSONValueTypeValueIncompatible) Error

type Executor

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

func NewExecutor

func NewExecutor(templateDirectives []byte_template.DirectiveDefinition) *Executor

func (*Executor) Execute

func (e *Executor) Execute(ctx Context, node RootNode, w io.Writer) error

func (*Executor) ResolveArgs

func (e *Executor) ResolveArgs(args []datasource.Argument, data []byte) ResolvedArgs

type Fetch

type Fetch interface {
	Fetch(ctx Context, data []byte, argsResolver ArgsResolver, suffix string, buffers *LockableBufferMap) (n int, err error)
}

type Field

type Field struct {
	Name            []byte
	Value           Node
	Skip            BooleanCondition
	HasResolvedData bool
}

func (*Field) HasResolversRecursively

func (f *Field) HasResolversRecursively() bool

func (*Field) Kind

func (*Field) Kind() NodeKind

type GraphqlRequest

type GraphqlRequest struct {
	OperationName string          `json:"operationName"`
	Variables     json.RawMessage `json:"variables"`
	Query         string          `json:"query"`
}

type Handler

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

func NewHandler

func NewHandler(base *datasource.BasePlanner, templateDirectives []byte_template.DirectiveDefinition) *Handler

func (*Handler) Handle

func (h *Handler) Handle(requestData, extraVariables []byte) (executor *Executor, node RootNode, ctx Context, err error)

type IfEqual

type IfEqual struct {
	Left, Right datasource.Argument
}

func (*IfEqual) Evaluate

func (i *IfEqual) Evaluate(ctx Context, data []byte) bool

type IfNotEqual

type IfNotEqual struct {
	Left, Right datasource.Argument
}

func (*IfNotEqual) Evaluate

func (i *IfNotEqual) Evaluate(ctx Context, data []byte) bool

type JSONValueType

type JSONValueType int
const (
	UnknownValueType JSONValueType = iota
	StringValueType
	IntegerValueType
	FloatValueType
	BooleanValueType
)

func (JSONValueType) String

func (i JSONValueType) String() string

type List

type List struct {
	DataResolvingConfig DataResolvingConfig
	Value               Node
	Filter              ListFilter
}

func (*List) HasResolversRecursively

func (l *List) HasResolversRecursively() bool

func (*List) Kind

func (*List) Kind() NodeKind

type ListFilter

type ListFilter interface {
	Kind() ListFilterKind
}

type ListFilterFirstN

type ListFilterFirstN struct {
	FirstN int
}

func (ListFilterFirstN) Kind

type ListFilterKind

type ListFilterKind int
const (
	ListFilterKindFirstN ListFilterKind = iota + 1
)

type LockableBufferMap

type LockableBufferMap struct {
	sync.Mutex
	Buffers map[uint64]*bytes.Buffer
}

type Node

type Node interface {
	// Kind returns the NodeKind of each Node
	Kind() NodeKind
	// HasResolversRecursively returns true if this Node or any child Node has a resolver
	HasResolversRecursively() bool
}

type NodeKind

type NodeKind int
const (
	ObjectKind NodeKind = iota + 1
	FieldKind
	ListKind
	ValueKind
)

type Object

type Object struct {
	DataResolvingConfig DataResolvingConfig
	Fields              []Field
	Fetch               Fetch
	// contains filtered or unexported fields
}

func (*Object) HasResolversRecursively

func (o *Object) HasResolversRecursively() bool

func (*Object) Kind

func (*Object) Kind() NodeKind

func (*Object) OperationType

func (o *Object) OperationType() ast.OperationType

type ParallelFetch

type ParallelFetch struct {
	Fetches []Fetch
	// contains filtered or unexported fields
}

func (*ParallelFetch) Fetch

func (p *ParallelFetch) Fetch(ctx Context, data []byte, argsResolver ArgsResolver, suffix string, buffers *LockableBufferMap) (n int, err error)

type PipelineTransformation

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

func (*PipelineTransformation) Transform

func (p *PipelineTransformation) Transform(input []byte) ([]byte, error)

type Planner

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

func NewPlanner

func NewPlanner(base *datasource.BasePlanner) *Planner

func (*Planner) Plan

func (p *Planner) Plan(operation, definition *ast.Document, operationName string, report *operationreport.Report) RootNode

type ResolvedArgs

type ResolvedArgs []ResolvedArgument

func (ResolvedArgs) ByKey

func (r ResolvedArgs) ByKey(key []byte) []byte

func (ResolvedArgs) Dump

func (r ResolvedArgs) Dump() []string

func (*ResolvedArgs) Filter

func (r *ResolvedArgs) Filter(condition func(i int) (keep bool))

func (ResolvedArgs) Keys

func (r ResolvedArgs) Keys() [][]byte

type ResolvedArgument

type ResolvedArgument struct {
	Key   []byte
	Value []byte
}

type RootNode

type RootNode interface {
	Node
	OperationType() ast.OperationType
}

type SerialFetch

type SerialFetch struct {
	Fetches []Fetch
}

func (*SerialFetch) Fetch

func (s *SerialFetch) Fetch(ctx Context, data []byte, argsResolver ArgsResolver, suffix string, buffers *LockableBufferMap) (n int, err error)

type SingleFetch

type SingleFetch struct {
	Source     *DataSourceInvocation
	BufferName string
}

func (*SingleFetch) Fetch

func (s *SingleFetch) Fetch(ctx Context, data []byte, argsResolver ArgsResolver, path string, buffers *LockableBufferMap) (int, error)

type Transformation

type Transformation interface {
	Transform(input []byte) ([]byte, error)
}

type Value

type Value struct {
	DataResolvingConfig DataResolvingConfig
	ValueType           JSONValueType
}

func (*Value) HasResolversRecursively

func (value *Value) HasResolversRecursively() bool

func (*Value) Kind

func (*Value) Kind() NodeKind

type Variables

type Variables map[uint64][]byte

func VariablesFromJson

func VariablesFromJson(requestVariables, extraVariables []byte) (variables Variables, extraArguments []datasource.Argument)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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