Documentation ¶
Overview ¶
Package gql is responsible for lexing and parsing a GraphQL query/mutation.
Index ¶
- Constants
- Variables
- func HasVariables(n *protos.NQuad) bool
- 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) ExpandVariables(newToUid map[string]uint64, subjectUids []uint64, objectUids []uint64) (edges []*protos.DirectedEdge, err error)
- func (nq NQuad) ToDeletePredEdge() (*protos.DirectedEdge, error)
- func (nq NQuad) ToEdgeUsing(newToUid map[string]uint64) (*protos.DirectedEdge, error)
- type NQuads
- type Request
- type Result
- type VarContext
- type Vars
Constants ¶
const ( ANY_VAR = 0 UID_VAR = 1 VALUE_VAR = 2 LIST_VAR = 3 )
Variables ¶
var (
ErrInvalidUID = errors.New("UID has to be greater than one.")
)
Functions ¶
func HasVariables ¶ added in v0.8.2
HasVariables returns true iff given NQuad refers some variable.
Types ¶
type FilterTree ¶ added in v0.7.0
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 ¶ added in v0.7.0
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) }
Function holds the information about gql functions.
func (*Function) IsAggregator ¶ added in v0.7.3
func (*Function) IsPasswordVerifier ¶ added in v0.7.3
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 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 Upsert bool // Whether we should add the edge in case it doesn't exist. // 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 ¶ added in v0.7.0
func (gq *GraphQuery) DebugPrint(prefix string)
DebugPrint is useful for debugging.
type Mutation ¶
Mutation stores the strings corresponding to set and delete operations.
func (Mutation) HasOps ¶ added in v0.8.2
HasOps returns true iff the mutation has at least one non-empty part.
func (Mutation) HasVariables ¶ added in v0.8.2
func (Mutation) NeededVars ¶ added in v0.8.2
NeededVars retrieves NQuads and variable names of NQuads that refer a variable.
type NQuad ¶ added in v0.8.2
func (NQuad) CreateUidEdge ¶ added in v0.8.2
func (nq NQuad) CreateUidEdge(subjectUid uint64, objectUid uint64) *protos.DirectedEdge
func (NQuad) CreateValueEdge ¶ added in v0.8.2
func (nq NQuad) CreateValueEdge(subjectUid uint64) (*protos.DirectedEdge, error)
func (*NQuad) ExpandVariables ¶ added in v0.8.2
func (NQuad) ToDeletePredEdge ¶ added in v0.8.2
func (nq NQuad) ToDeletePredEdge() (*protos.DirectedEdge, error)
func (NQuad) ToEdgeUsing ¶ added in v0.8.2
ToEdgeUsing determines the UIDs for the provided XIDs and populates the xidToUid map.
type NQuads ¶ added in v0.8.2
type NQuads struct { NQuads []*protos.NQuad Types []protos.DirectedEdge_Op }
func (*NQuads) SetTypes ¶ added in v0.8.2
func (n *NQuads) SetTypes(t protos.DirectedEdge_Op)
type Result ¶ added in v0.7.2
type Result struct { Query []*GraphQuery QueryVars []*Vars Mutation *Mutation MutationVars []string Schema *protos.SchemaRequest }
Result struct contains the Query list, its corresponding variable use list and the mutation block.