graphql: github.com/graphql-go/graphql/language/visitor Index | Files

package visitor

import "github.com/graphql-go/graphql/language/visitor"

Index

Package Files

visitor.go

Constants

const (
    ActionNoChange = ""
    ActionBreak    = "BREAK"
    ActionSkip     = "SKIP"
    ActionUpdate   = "UPDATE"
)

Variables

var QueryDocumentKeys = KeyMap{
    "Name":     []string{},
    "Document": []string{"Definitions"},
    "OperationDefinition": []string{
        "Name",
        "VariableDefinitions",
        "Directives",
        "SelectionSet",
    },
    "VariableDefinition": []string{
        "Variable",
        "Type",
        "DefaultValue",
    },
    "Variable":     []string{"Name"},
    "SelectionSet": []string{"Selections"},
    "Field": []string{
        "Alias",
        "Name",
        "Arguments",
        "Directives",
        "SelectionSet",
    },
    "Argument": []string{
        "Name",
        "Value",
    },

    "FragmentSpread": []string{
        "Name",
        "Directives",
    },
    "InlineFragment": []string{
        "TypeCondition",
        "Directives",
        "SelectionSet",
    },
    "FragmentDefinition": []string{
        "Name",
        "TypeCondition",
        "Directives",
        "SelectionSet",
    },

    "IntValue":     []string{},
    "FloatValue":   []string{},
    "StringValue":  []string{},
    "BooleanValue": []string{},
    "EnumValue":    []string{},
    "ListValue":    []string{"Values"},
    "ObjectValue":  []string{"Fields"},
    "ObjectField": []string{
        "Name",
        "Value",
    },

    "Directive": []string{
        "Name",
        "Arguments",
    },

    "Named":   []string{"Name"},
    "List":    []string{"Type"},
    "NonNull": []string{"Type"},

    "SchemaDefinition": []string{
        "Directives",
        "OperationTypes",
    },
    "OperationTypeDefinition": []string{"Type"},

    "ScalarDefinition": []string{
        "Name",
        "Directives",
    },
    "ObjectDefinition": []string{
        "Name",
        "Interfaces",
        "Directives",
        "Fields",
    },
    "FieldDefinition": []string{
        "Name",
        "Arguments",
        "Type",
        "Directives",
    },
    "InputValueDefinition": []string{
        "Name",
        "Type",
        "DefaultValue",
        "Directives",
    },
    "InterfaceDefinition": []string{
        "Name",
        "Directives",
        "Fields",
    },
    "UnionDefinition": []string{
        "Name",
        "Directives",
        "Types",
    },
    "EnumDefinition": []string{
        "Name",
        "Directives",
        "Values",
    },
    "EnumValueDefinition": []string{
        "Name",
        "Directives",
    },
    "InputObjectDefinition": []string{
        "Name",
        "Directives",
        "Fields",
    },

    "TypeExtensionDefinition": []string{"Definition"},

    "DirectiveDefinition": []string{"Name", "Arguments", "Locations"},
}

note that the keys are in Capital letters, equivalent to the ast.Node field Names

func Visit Uses

func Visit(root ast.Node, visitorOpts *VisitorOptions, keyMap KeyMap) interface{}

type KeyMap Uses

type KeyMap map[string][]string

type NamedVisitFuncs Uses

type NamedVisitFuncs struct {
    Kind  VisitFunc // 1) Named visitors triggered when entering a node a specific kind.
    Leave VisitFunc // 2) Named visitors that trigger upon entering and leaving a node of
    Enter VisitFunc // 2) Named visitors that trigger upon entering and leaving a node of
}

type VisitFunc Uses

type VisitFunc func(p VisitFuncParams) (string, interface{})

func GetVisitFn Uses

func GetVisitFn(visitorOpts *VisitorOptions, kind string, isLeaving bool) VisitFunc

GetVisitFn Given a visitor instance, if it is leaving or not, and a node kind, return the function the visitor runtime should call. priority [high->low] in VisitorOptions: KindFuncMap{Kind> {Leave, Enter}} > {Leave, Enter} > {EnterKindMap, LeaveKindMap}

type VisitFuncParams Uses

type VisitFuncParams struct {
    Node      interface{}
    Key       interface{}
    Parent    ast.Node
    Path      []interface{}
    Ancestors []ast.Node
}

type VisitorOptions Uses

type VisitorOptions struct {
    KindFuncMap map[string]NamedVisitFuncs
    Enter       VisitFunc // 3) Generic visitors that trigger upon entering and leaving any node.
    Leave       VisitFunc // 3) Generic visitors that trigger upon entering and leaving any node.

    EnterKindMap map[string]VisitFunc // 4) Parallel visitors for entering and leaving nodes of a specific kind
    LeaveKindMap map[string]VisitFunc // 4) Parallel visitors for entering and leaving nodes of a specific kind
}

func VisitInParallel Uses

func VisitInParallel(visitorOptsSlice ...*VisitorOptions) *VisitorOptions

VisitInParallel Creates a new visitor instance which delegates to many visitors to run in parallel. Each visitor will be visited for each node before moving on.

If a prior visitor edits a node, no following visitors will see that node.

func VisitWithTypeInfo Uses

func VisitWithTypeInfo(ttypeInfo typeInfo.TypeInfoI, visitorOpts *VisitorOptions) *VisitorOptions

VisitWithTypeInfo Creates a new visitor instance which maintains a provided TypeInfo instance along with visiting visitor.

Package visitor imports 4 packages (graph) and is imported by 53 packages. Updated 2018-10-04. Refresh now. Tools for package owners.