execution

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplySelectionSet

func ApplySelectionSet(schema *internal.Schema, document *internal.Document, operationName string, vars map[string]interface{}) (
	ast.OperationType, *internal.SelectionSet, error)

func Do

func Do(schema *internal.Schema, param Params) (interface{}, errors.MultiError)

func Flatten

func Flatten(selectionSet *internal.SelectionSet) ([]*internal.Selection, error)

Flatten takes a SelectionSet and flattens it into an array of selections with unique aliases

A GraphQL query (the SelectionSet) is allowed to contain the same key multiple times, as well as fragments. For example,

{
  groups { name }
  groups { name id }
  ... on Organization { groups { widgets { name } } }
}

Flatten simplifies the query into an array of selections, merging fields, resulting in something like the new query

groups: { name name id { widgets { name } } }

Flatten does _not_ flatten out the inner queries, so the name above does not get flattened out yet.

Types

type Executor

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

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, typ internal.Type, source interface{},
	selectionSet *internal.SelectionSet) (interface{}, errors.MultiError)

type Params

type Params struct {
	Query         string                 `json:"query"`
	OperationName string                 `json:"operationName"`
	Variables     map[string]interface{} `json:"variables"`
	Context       context.Context        `json:"context"`
}

Jump to

Keyboard shortcuts

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