(gq *dql.GraphQuery, sg *SubGraph)
| 527 | } |
| 528 | |
| 529 | func treeCopy(gq *dql.GraphQuery, sg *SubGraph) error { |
| 530 | // Typically you act on the current node, and leave recursion to deal with |
| 531 | // children. But, in this case, we don't want to muck with the current |
| 532 | // node, because of the way we're dealing with the root node. |
| 533 | // So, we work on the children, and then recurse for grand children. |
| 534 | attrsSeen := make(map[string]struct{}) |
| 535 | |
| 536 | for _, gchild := range gq.Children { |
| 537 | if sg.Params.Alias == "shortest" && gchild.Expand != "" { |
| 538 | return errors.Errorf("expand() not allowed inside shortest") |
| 539 | } |
| 540 | |
| 541 | key := "" |
| 542 | if gchild.Alias != "" { |
| 543 | key = gchild.Alias |
| 544 | } else { |
| 545 | key = uniqueKey(gchild) |
| 546 | } |
| 547 | if _, ok := attrsSeen[key]; ok { |
| 548 | return errors.Errorf("%s not allowed multiple times in same sub-query.", |
| 549 | key) |
| 550 | } |
| 551 | attrsSeen[key] = struct{}{} |
| 552 | |
| 553 | args := params{ |
| 554 | Alias: gchild.Alias, |
| 555 | Expand: gchild.Expand, |
| 556 | Facet: gchild.Facets, |
| 557 | FacetsOrder: gchild.FacetsOrder, |
| 558 | FacetVar: gchild.FacetVar, |
| 559 | GetUid: sg.Params.GetUid, |
| 560 | IgnoreReflex: sg.Params.IgnoreReflex, |
| 561 | Langs: gchild.Langs, |
| 562 | NeedsVar: append(gchild.NeedsVar[:0:0], gchild.NeedsVar...), |
| 563 | Normalize: gchild.Normalize || sg.Params.Normalize, |
| 564 | Order: gchild.Order, |
| 565 | Var: gchild.Var, |
| 566 | GroupbyAttrs: gchild.GroupbyAttrs, |
| 567 | IsGroupBy: gchild.IsGroupby, |
| 568 | IsInternal: gchild.IsInternal, |
| 569 | Cascade: &CascadeArgs{}, |
| 570 | } |
| 571 | |
| 572 | // Inherit from the parent. |
| 573 | if len(sg.Params.Cascade.Fields) > 0 { |
| 574 | args.Cascade.Fields = append(args.Cascade.Fields, sg.Params.Cascade.Fields...) |
| 575 | } |
| 576 | // Allow over-riding at this level. |
| 577 | if len(gchild.Cascade) > 0 { |
| 578 | args.Cascade.Fields = gchild.Cascade |
| 579 | } |
| 580 | |
| 581 | // Remove pagination arguments from the query if @cascade is mentioned since |
| 582 | // pagination will be applied post processing the data. |
| 583 | if len(args.Cascade.Fields) > 0 { |
| 584 | args.addCascadePaginationArguments(gchild) |
| 585 | } |
| 586 |
no test coverage detected