# tests/cypher/corpus/library.jsonl, method subgraph
query: "MATCH (s:Document {`path`: $s_val}) MATCH p = (s)-[*0..2]-(o) WHERE ($edge_types IS NULL OR all(x IN relationships(p) WHERE type(x) IN $edge_types)) AND (any(l IN labels(s) WHERE l IN $scope_catalog_labels) OR (s.tenant_id = $scope_tenant AND (s.created_by_user_id IN $scope_user_ids OR any(x IN $scope_user_ids WHERE x IN coalesce(s.created_by_user_ids, []))))) AND (any(l IN labels(o) WHERE l IN $scope_catalog_labels) OR (o.tenant_id = $scope_tenant AND (o.created_by_user_id IN $scope_user_ids OR any(x IN $scope_user_ids WHERE x IN coalesce(o.created_by_user_ids, []))))) AND all(m IN nodes(p)[1..-1] WHERE m.tenant_id = $scope_tenant) WITH collect(DISTINCT o)[0..$max_nodes] AS ns RETURN [n IN ns | n { .*, _labels: labels(n) }] AS nodes, reduce(acc = [], n1 IN ns | acc + [(n1)-[e]->(n2) WHERE n2 IN ns AND ($edge_types IS NULL OR type(e) IN $edge_types) | {type: type(e), props: properties(e)}]) AS rels"
---
Match optional=False
  Path var=None selector=None
    Node var=s labels=(Document) props={path: (Param s_val)} where=None
  where=None
Match optional=False
  Path var=p selector=None
    Node var=s labels=* props={} where=None
    Quantified min=0 max=2
      Node var=__a0 labels=* props={} where=None
      Rel var=__r0 types=* dir=both props={} where=None
      Node var=__a1 labels=* props={} where=None
    Node var=o labels=* props={} where=None
  where=(AND (AND (AND (OR (IS NULL (Param edge_types)) (all x (Func relationships (Var p)) where=(IN (Func type (Var x)) (Param edge_types)))) (OR (any l (Func labels (Var s)) where=(IN (Var l) (Param scope_catalog_labels))) (AND (= (Prop (Var s) tenant_id) (Param scope_tenant)) (OR (IN (Prop (Var s) created_by_user_id) (Param scope_user_ids)) (any x (Param scope_user_ids) where=(IN (Var x) (Func coalesce (Prop (Var s) created_by_user_ids) (List)))))))) (OR (any l (Func labels (Var o)) where=(IN (Var l) (Param scope_catalog_labels))) (AND (= (Prop (Var o) tenant_id) (Param scope_tenant)) (OR (IN (Prop (Var o) created_by_user_id) (Param scope_user_ids)) (any x (Param scope_user_ids) where=(IN (Var x) (Func coalesce (Prop (Var o) created_by_user_ids) (List)))))))) (all m (Slice (Func nodes (Var p)) (Lit 1) (Lit -1)) where=(= (Prop (Var m) tenant_id) (Param scope_tenant))))
With distinct=False order=() skip=None limit=None
  ns = (Slice (Func collect DISTINCT (Var o)) (Lit 0) (Param max_nodes))
  where=None
Return distinct=False order=() skip=None limit=None
  nodes = (ListComp n (Var ns) where=None project=(MapProjection (Var n) .* (_labels (Func labels (Var n)))))
  rels = (Reduce acc (List) n1 (Var ns) (+ (Var acc) (PatternComp #0)))
    #0 PatternComp
      Path var=None selector=None
        Node var=n1 labels=* props={} where=None
        Rel var=e types=* dir=out props={} where=None
        Node var=n2 labels=* props={} where=None
      where=(AND (IN (Var n2) (Var ns)) (OR (IS NULL (Param edge_types)) (IN (Func type (Var e)) (Param edge_types))))
      project=(Map (type (Func type (Var e))) (props (Func properties (Var e))))
