 (p.misc/spec-doc ::index-syms "An index from resolver symbol to a set of execution nodes where its used.")
 (p.misc/spec-doc ::node-id "ID for a execution node in the planner graph.")
 (p.misc/spec-doc ::nodes "The nodes index.")
-(p.misc/spec-doc ::previous-out "Graph before modifications, this is used to restore previous graph when some path ends up being unreachable.")
+(p.misc/spec-doc ::previous-graph "Graph before modifications, this is used to restore previous graph when some path ends up being unreachable.")
 (p.misc/spec-doc ::provides "An IO-MAP description of what will be provided once the node and its dependencies finishing running.")
 (p.misc/spec-doc ::requires "An IO-MAP description of what is required from this execution node to returns.")
 (p.misc/spec-doc ::root "A node-id that defines the root in the planner graph.")

          (and sym (dynamic-resolver? env sym))
          (update ::dynamic-resolvers p.misc/sconj sym)))))

(defn merge-nodes-provides [out nodes]
  (transduce
    (keep #(get-in out [::nodes % ::provides]))
    merge-io
    {}
    nodes))

        (add-branch-node env node))))

(defn compute-root-branch
  [graph
   {::keys [branch-type] :as env}
   {::keys [node-id]}
   branch-node-factory]
  (if node-id
    (let [root-node (get-root-node graph)
          next-node (get-node graph node-id)]
      (cond
        (not root-node)
        (assoc graph ::root node-id)

        (get next-node branch-type)
        (add-branch-node (assoc graph ::root node-id) env root-node)

        (get root-node branch-type)
        (add-branch-node graph env next-node)

        :else
        (create-branch-node graph env next-node (branch-node-factory))))
    graph))

(defn compute-root-or
  [{::keys [root] :as graph}
   {:com.wsscode.pathom.connect/keys [attribute] :as env}
   node]
  (if (= root (::node-id node))
    graph
    (compute-root-branch graph (assoc env ::branch-type ::run-or) node
      (fn []
        {::node-id  (next-node-id env)
         ::requires {attribute {}}
         ::provides (-> graph get-root-node ::provides)
         ::run-or   [(::root graph)]}))))

(defn compute-root-and
  [{::keys [root] :as graph} env node]
  (if (= root (::node-id node))
    graph
    (compute-root-branch graph (assoc env ::branch-type ::run-and) node
      (fn []
        (let [{::keys [requires provides]} (get-root-node graph)]
          {::node-id  (next-node-id env)
           ::requires requires
           ::provides provides
           ::run-and  [(::root graph)]})))))

(def dynamic-base-provider-sym `run-graph-base-provider)

