MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / updateVars

Method updateVars

query/query.go:1535–1547  ·  view source on GitHub ↗

updateVars is used to update the doneVars map with the value of the variable from the SubGraph. The variable could be a uid or a value variable. It is called twice 1. To populate sg.Params.ParentVars map with the value of a variable to pass down to children subgraphs in a query. 2. To populate req.V

(doneVars map[string]varValue, sgPath []*SubGraph)

Source from the content-addressed store, hash-verified

1533// subgraphs in a query.
1534// 2. To populate req.Vars, which is used by other queries requiring variables..
1535func (sg *SubGraph) updateVars(doneVars map[string]varValue, sgPath []*SubGraph) error {
1536 // NOTE: although we initialize doneVars (req.Vars) in ProcessQuery, this nil check is for
1537 // non-root lookups that happen to other nodes. Don't use len(doneVars) == 0 !
1538 if doneVars == nil || (sg.Params.Var == "" && sg.Params.FacetVar == nil) {
1539 return nil
1540 }
1541
1542 sgPathCopy := append(sgPath[:0:0], sgPath...)
1543 if err := sg.populateUidValVar(doneVars, sgPathCopy); err != nil {
1544 return err
1545 }
1546 return sg.populateFacetVars(doneVars, sgPathCopy)
1547}
1548
1549// populateUidValVar populates the value of the variable into doneVars.
1550func (sg *SubGraph) populateUidValVar(doneVars map[string]varValue, sgPath []*SubGraph) error {

Callers 2

populateVarMapMethod · 0.95
ProcessGraphFunction · 0.80

Calls 2

populateUidValVarMethod · 0.95
populateFacetVarsMethod · 0.95

Tested by

no test coverage detected