Documentation ¶
Overview ¶
Package gql is responsible for lexing and parsing a GraphQL query/mutation.
Index ¶
- Constants
- Variables
- func ParseMutation(mutation string) (*protos.Mutation, error)
- func ParseUid(xid string) (uint64, error)
- type Arg
- type AttrLang
- type Count
- type Facets
- type FilterTree
- type Function
- type GraphQuery
- type MathTree
- type Mutation
- type NQuad
- func (nq NQuad) CreateUidEdge(subjectUid uint64, objectUid uint64) *protos.DirectedEdge
- func (nq NQuad) CreateValueEdge(subjectUid uint64) (*protos.DirectedEdge, error)
- func (nq NQuad) ToDeletePredEdge() (*protos.DirectedEdge, error)
- func (nq NQuad) ToEdgeUsing(newToUid map[string]uint64) (*protos.DirectedEdge, error)
- type Request
- type Result
- type VarContext
- type Vars
Constants ¶
View Source
const ( ANY_VAR = 0 UID_VAR = 1 VALUE_VAR = 2 LIST_VAR = 3 )
Variables ¶
View Source
var (
ErrInvalidUID = errors.New("UID has to be greater than one.")
)
Functions ¶
Types ¶
type FilterTree ¶
type FilterTree struct { Op string Child []*FilterTree Func *Function }
FilterTree is the result of parsing the filter directive. Either you can have `Op and Children` on non-leaf nodes Or Func at leaf nodes.
type Function ¶
type Function struct { Attr string Lang string // language of the attribute value Name string // Specifies the name of the function. Args []Arg // Contains the arguments of the function. UID []uint64 NeedsVar []VarContext // If the function requires some variable IsCount bool // gt(count(friends),0) IsValueVar bool // eq(val(s), 5) }
Function holds the information about gql functions.
func (*Function) IsAggregator ¶
func (*Function) IsPasswordVerifier ¶
type GraphQuery ¶
type GraphQuery struct { UID []uint64 Attr string Langs []string Alias string IsCount bool IsInternal bool IsGroupby bool Var string NeedsVar []VarContext Func *Function Expand string // Which variable to expand with. Args map[string]string // Query can have multiple sort parameters. Order []*protos.Order Children []*GraphQuery Filter *FilterTree MathExp *MathTree Normalize bool Recurse bool Cascade bool IgnoreReflex bool Facets *Facets FacetsFilter *FilterTree GroupbyAttrs []AttrLang FacetVar map[string]string FacetOrder string FacetDesc bool // Indicates whether count of uids is requested as a child node. If // there is a child with count() attr, then this is not empty for the parent. // If there is an alias, this has the alias value, else its value is count. UidCount string // True for blocks that don't have a starting function and hence no starting nodes. They are // used to aggregate and get variables defined in another block. IsEmpty bool // contains filtered or unexported fields }
GraphQuery stores the parsed Query in a tree format. This gets converted to internally used query.SubGraph before processing the query.
func (*GraphQuery) DebugPrint ¶
func (gq *GraphQuery) DebugPrint(prefix string)
DebugPrint is useful for debugging.
type NQuad ¶
func (NQuad) CreateUidEdge ¶
func (nq NQuad) CreateUidEdge(subjectUid uint64, objectUid uint64) *protos.DirectedEdge
func (NQuad) CreateValueEdge ¶
func (nq NQuad) CreateValueEdge(subjectUid uint64) (*protos.DirectedEdge, error)
func (NQuad) ToDeletePredEdge ¶
func (nq NQuad) ToDeletePredEdge() (*protos.DirectedEdge, error)
func (NQuad) ToEdgeUsing ¶
ToEdgeUsing determines the UIDs for the provided XIDs and populates the xidToUid map.
type Result ¶
type Result struct { Query []*GraphQuery QueryVars []*Vars Schema *protos.SchemaRequest }
Result struct contains the Query list, its corresponding variable use list and the mutation block.
type VarContext ¶
Click to show internal directories.
Click to hide internal directories.