executor

package
v0.0.0-...-3478735 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteRequest

func ExecuteRequest(ctx context.Context, r *Request) (*OrderedMap, []*Error)

ExecuteRequest executes a request.

func IsSubscription

func IsSubscription(doc *ast.Document, operationName string) bool

IsSubscription can be used to determine if a request is for a subscription.

Types

type Error

type Error struct {
	// Executor error messages are formatted as sentences, e.g. "An error occurred."
	Message string

	// Nearly all errors have locations, which point to one or more relevant query tokens.
	Locations []Location

	// If the error occurred during the resolution of a particular field, a path will be present.
	Path []interface{}
	// contains filtered or unexported fields
}

Error represents an execution error.

func GetOperation

func GetOperation(doc *ast.Document, operationName string) (*ast.OperationDefinition, *Error)

GetOperation returns the operation selected by the given name. If operationName is "" and the document contains only one operation, it is returned. Otherwise the document must contain exactly one operation with the given name.

func Subscribe

func Subscribe(ctx context.Context, r *Request) (any, *Error)

Subscribe resolves the root subscription field of a request and returns the result.

func (*Error) Error

func (err *Error) Error() string

func (*Error) Unwrap

func (err *Error) Unwrap() error

If the error came from a resolver, you can get the original error with Unwrap.

type GroupedFieldSet

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

GroupedFieldSet holds the results of the GraphQL CollectFields algorithm.

func NewGroupedFieldSetWithCapacity

func NewGroupedFieldSetWithCapacity(n int) *GroupedFieldSet

NewGroupedFieldSetWithCapacity allocates a GroupedFieldSet with capacity for n elements.

func (*GroupedFieldSet) Append

func (m *GroupedFieldSet) Append(key string, field *ast.Field)

Append appends a field to the list for the given key.

func (*GroupedFieldSet) Items

func (m *GroupedFieldSet) Items() []GroupedFieldSetItem

Items returns the items in the GroupedFieldSet, in the order they were added.

func (*GroupedFieldSet) Len

func (m *GroupedFieldSet) Len() int

Len returns the length of the GroupedFieldSet

type GroupedFieldSetItem

type GroupedFieldSetItem struct {
	Key    string
	Fields []*ast.Field
}

GroupedFieldSetItem contains a key and field list pair in a GroupedFieldSet.

type Location

type Location struct {
	Line   int
	Column int
}

Location represents the location of a character within a query's source text.

type OrderedMap

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

OrderedMap represents a map that maintains the order of its key-value pairs. It's more or less just a list that serializes to a JSON map.

func NewOrderedMap

func NewOrderedMap() *OrderedMap

NewOrderedMap creates a new ordered map.

func NewOrderedMapWithLength

func NewOrderedMapWithLength(n int) *OrderedMap

NewOrderedMapWithLength creates a new ordered map with n elements pre-allocated and zero-initialized.

func (*OrderedMap) Append

func (m *OrderedMap) Append(key string, value interface{})

Append appends a key-value pair to the map. It is the caller's responsibility to make sure the key doesn't already exist in the map.

func (*OrderedMap) Items

func (m *OrderedMap) Items() []OrderedMapItem

Items provides the items in the map, in the order they were added.

func (*OrderedMap) Len

func (m *OrderedMap) Len() int

Len returns the length of the map.

func (*OrderedMap) MarshalJSON

func (m *OrderedMap) MarshalJSON() ([]byte, error)

MarshalJSON marshals the map to JSON, maintaining the correct key order.

func (*OrderedMap) Set

func (m *OrderedMap) Set(index int, key string, value interface{})

Set writes a key-value pair to the map at the given index.

type OrderedMapItem

type OrderedMapItem struct {
	Key   string
	Value interface{}
}

OrderedMapItem is a key-value pair for an item in an OrderedMap.

type Request

type Request struct {
	Document       *ast.Document
	Schema         *schema.Schema
	OperationName  string
	VariableValues map[string]any
	Features       schema.FeatureSet
	InitialValue   any
	IdleHandler    func()
}

Request defines all of the inputs required to execute a GraphQL query.

type ResolvePromise

type ResolvePromise chan ResolveResult

ResolvePromise can be used to resolve fields asynchronously. You may return ResolvePromise from the field's resolve function. If you do, you must define an IdleHandler for the request. Any time request execution is unable to proceed, the idle handler will be invoked. Before the idle handler returns, a result must be sent to at least one previously returned ResolvePromise.

type ResolveResult

type ResolveResult struct {
	Value any
	Error error
}

ResolveResult represents the result of a field resolver. This type is generally used with ResolvePromise to pass around asynchronous results.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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