Documentation ¶
Index ¶
- func ExecuteRequest(ctx context.Context, r *Request) (*OrderedMap, []*Error)
- func IsSubscription(doc *ast.Document, operationName string) bool
- type Error
- type GroupedFieldSet
- type GroupedFieldSetItem
- type Location
- type OrderedMap
- type OrderedMapItem
- type Request
- type ResolvePromise
- type ResolveResult
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.
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 ¶
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.
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 ¶
GroupedFieldSetItem contains a key and field list pair in a GroupedFieldSet.
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 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) 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 ¶
ResolveResult represents the result of a field resolver. This type is generally used with ResolvePromise to pass around asynchronous results.