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)
| 1533 | // subgraphs in a query. |
| 1534 | // 2. To populate req.Vars, which is used by other queries requiring variables.. |
| 1535 | func (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. |
| 1550 | func (sg *SubGraph) populateUidValVar(doneVars map[string]varValue, sgPath []*SubGraph) error { |
no test coverage detected