(add-branch-to-node graph target-node-id branch-type new-branch-node-id)
(add-ident-process graph {:keys [key]})
(add-node-branches graph target-node-id branch-type node-ids)
(add-node-parent graph node-id node-parent-id)
(add-placeholder-entry graph attr)
(add-snapshot! graph
{:com.wsscode.pathom3.connect.planner/keys [snapshots*
snapshot-depth]}
event-details)
(add-unreachable-path graph env path)
Add attribute to unreachable list
Add attribute to unreachable list
(add-warning graph warn)
(assoc-node graph node-id k v)
Set attribute k about node-id. Only assoc when node exists, otherwise its a noop.
Set attribute k about node-id. Only assoc when node exists, otherwise its a noop.
(base-env)
(base-graph)
(branch-node? node)
Returns true when the node is a branch node type.
Returns true when the node is a branch node type.
(can-merge-sibling-resolver-nodes? graph node-id1 node-id2)
(combine-expects na nb)
(combine-foreign-ast na nb)
(combine-inputs na nb)
(combine-run-next graph env node-ids pivot)
(compute-attribute-dependency-graph
graph
{:com.wsscode.pathom3.connect.planner/keys [recursive-joins] :as env}
attr
shape)
(compute-attribute-graph
{:com.wsscode.pathom3.connect.planner/keys [unreachable-paths] :as graph}
{:com.wsscode.pathom3.connect.planner/keys [attr-deps-trail]
:com.wsscode.pathom3.connect.indexes/keys [index-oir]
{attr :key} :edn-query-language.ast/node
:as env})
Compute the run graph for a given attribute.
Compute the run graph for a given attribute.
(compute-attribute-graph* graph
{:com.wsscode.pathom3.connect.indexes/keys [index-oir]
:com.wsscode.pathom3.attribute/keys [attribute]
:as env})
Traverse the attribute options, for example, considering we are processing the
attribute :a
. And we have this index:
{::pci/index-oir {:a {{} #{a}}}}
This means we are now at the {{} #{a}}
part, lets call each entry of this map a
process path
.
To break it down, in this case we have one process path
to get :a
. Each process
pair contains an input shape and a set of resolvers.
You can read it as: I can fetch :a
providing the data {}
to the resolver a
.
A bigger example:
{::pci/index-oir {:a {{:b {}} #{a-from-b}
{:c {}} #{a-from-c a-f-c}}}}
In this case we have two process paths.
This function iterates over each process path, if at least one can complete the path, it returns a graph with a root o the node. In case of many options, an OR node will be the root, providing each path.
Traverse the attribute options, for example, considering we are processing the attribute `:a`. And we have this index: {::pci/index-oir {:a {{} #{a}}}} This means we are now at the `{{} #{a}}` part, lets call each entry of this map a `process path`. To break it down, in this case we have one `process path` to get `:a`. Each process pair contains an input shape and a set of resolvers. You can read it as: I can fetch `:a` providing the data `{}` to the resolver `a`. A bigger example: {::pci/index-oir {:a {{:b {}} #{a-from-b} {:c {}} #{a-from-c a-f-c}}}} In this case we have two process paths. This function iterates over each process path, if at least one can complete the path, it returns a graph with a root o the node. In case of many options, an OR node will be the root, providing each path.
(compute-attribute-nested-input-require graph env attr shape nodes)
(compute-dynamic-nested-requirements
{:com.wsscode.pathom3.attribute/keys [attribute]
:com.wsscode.pathom3.connect.operation/keys [op-name]
ast :edn-query-language.ast/node
:as env})
Considering the operation output, find out what a query can extend during nesting.
Pathom uses it to compute the dynamic requirements to send into dynamic resolvers.
This function is a useful tool for developers of custom dynamic resolvers.
Considering the operation output, find out what a query can extend during nesting. Pathom uses it to compute the dynamic requirements to send into dynamic resolvers. This function is a useful tool for developers of custom dynamic resolvers.
(compute-input-resolvers-graph graph
{:com.wsscode.pathom3.connect.planner/keys
[available-data]
:com.wsscode.pathom3.attribute/keys [attribute]
:as env}
input
resolvers)
This function computes the graph for a given process path
. It creates the resolver
nodes to execute the resolvers, in case of many resolvers it uses a OR node to combine
them.
Them it fetches the dependencies, declared in the process path. If the dependencies are successfully computed, it returns the graph with the root on the node that fulfills the request.
This function computes the graph for a given `process path`. It creates the resolver nodes to execute the resolvers, in case of many resolvers it uses a OR node to combine them. Them it fetches the dependencies, declared in the process path. If the dependencies are successfully computed, it returns the graph with the root on the node that fulfills the request.
(compute-missing-chain graph env missing missing-optionals)
Start a recursive call to process the dependencies required by the resolver.
Start a recursive call to process the dependencies required by the resolver.
(compute-missing-chain-deps
graph
{:com.wsscode.pathom3.connect.planner/keys [available-data] :as env}
missing)
(compute-missing-chain-optional-deps
graph
{:com.wsscode.pathom3.connect.planner/keys [available-data] :as env}
opt-missing
node-map)
(compute-non-index-attribute graph
{:com.wsscode.pathom3.connect.planner/keys
[available-data]
{attr :key :as ast} :edn-query-language.ast/node
:as env})
This function deals with attributes that are not part of the index execution. The cases here are:
This function deals with attributes that are not part of the index execution. The cases here are: - EQL idents - Previously available data - Placeholders
(compute-plan-snapshots env)
Run compute graph capturing snapshots, return the snapshots vector in the end.
Run compute graph capturing snapshots, return the snapshots vector in the end.
(compute-resolver-leaf graph
{:com.wsscode.pathom3.connect.planner/keys [input]
:as env}
resolvers)
For a set of resolvers (the R part of OIR index), create one OR node that branches to each option in the set.
For a set of resolvers (the R part of OIR index), create one OR node that branches to each option in the set.
(compute-run-graph env)
(compute-run-graph graph
{:com.wsscode.pathom3.connect.planner/keys [optimize-graph?]
:or {optimize-graph? true}
:as env})
Generates a run plan for a given environment, the environment should contain the indexes in it (::pc/index-oir and ::pc/index-resolvers). It computes a plan to execute one level of an AST, the AST must be provided via the key :edn-query-language.ast/node.
(compute-run-graph (assoc indexes :edn-query-language.ast/node ...))
The resulting graph will look like this:
{::nodes {1 {::pco/op-name a
::node-id 1
::requires {:a {}}
::input {}
::source-for-attrs #{:a}
::node-parents #{3}}
2 {::pco/op-name b
::node-id 2
::requires {:b {}}
::input {}
::source-for-attrs #{:b}
::node-parents #{3}}
3 {::node-id 3
::requires {:b {} :a {} :c {}}
::run-and #{2 1 4}}
4 {::pco/op-name c
::node-id 4
::requires {:c {}}
::input {}
::source-for-attrs #{:c}
::node-parents #{3}}}
::index-resolver->nodes {a #{1} b #{2} c #{4}}
::unreachable-attrs #{}
::index-attrs {:a #{1} :b #{2} :c #{4}}
::root 3}
Generates a run plan for a given environment, the environment should contain the indexes in it (::pc/index-oir and ::pc/index-resolvers). It computes a plan to execute one level of an AST, the AST must be provided via the key :edn-query-language.ast/node. (compute-run-graph (assoc indexes :edn-query-language.ast/node ...)) The resulting graph will look like this: {::nodes {1 {::pco/op-name a ::node-id 1 ::requires {:a {}} ::input {} ::source-for-attrs #{:a} ::node-parents #{3}} 2 {::pco/op-name b ::node-id 2 ::requires {:b {}} ::input {} ::source-for-attrs #{:b} ::node-parents #{3}} 3 {::node-id 3 ::requires {:b {} :a {} :c {}} ::run-and #{2 1 4}} 4 {::pco/op-name c ::node-id 4 ::requires {:c {}} ::input {} ::source-for-attrs #{:c} ::node-parents #{3}}} ::index-resolver->nodes {a #{1} b #{2} c #{4}} ::unreachable-attrs #{} ::index-attrs {:a #{1} :b #{2} :c #{4}} ::root 3}
(compute-run-graph* graph env)
Starts scanning the AST to plan for each attribute.
Starts scanning the AST to plan for each attribute.
(create-and graph env node-ids)
(create-node-for-resolver-call
{:com.wsscode.pathom3.connect.planner/keys [input]
:com.wsscode.pathom3.attribute/keys [attribute]
:com.wsscode.pathom3.connect.operation/keys [op-name]
ast :edn-query-language.ast/node
:as env})
Create a new node representative to run a given resolver.
Create a new node representative to run a given resolver.
(create-root-and graph env node-ids)
(create-root-or graph
{:com.wsscode.pathom3.attribute/keys [attribute] :as env}
node-ids)
(disj-rem m k item)
(entry-ast graph k)
Find AST node a given entry from the source AST.
Find AST node a given entry from the source AST.
(extend-attribute-sub-query graph attr shape)
(extend-available-attribute-nested
graph
{:com.wsscode.pathom3.connect.planner/keys [available-data] :as env}
attr
shape)
(find-direct-node-successors
{:com.wsscode.pathom3.connect.planner/keys [run-next] :as node})
Direct successors of node, branch nodes and run-next, in case of branch nodes the branches will always come before the run-next.
Direct successors of node, branch nodes and run-next, in case of branch nodes the branches will always come before the run-next.
(find-leaf-node graph node)
Traverses all run-next still it reaches a leaf.
Traverses all run-next still it reaches a leaf.
(find-root-resolver-nodes {:com.wsscode.pathom3.connect.planner/keys [root]
:as graph})
Returns the first resolvers to get called in the graph. This will traverse AND and OR node branches until the first resolvers are found. This function doesn't work the run-next of nodes.
Returns the first resolvers to get called in the graph. This will traverse AND and OR node branches until the first resolvers are found. This function doesn't work the run-next of nodes.
(find-run-next-descendants graph
{:com.wsscode.pathom3.connect.planner/keys
[node-id]})
Return descendants by walking the run-next
Return descendants by walking the run-next
(get-node graph node-id)
(get-node graph node-id k)
(get-root-node {:com.wsscode.pathom3.connect.planner/keys [root] :as graph})
Returns the root node of the graph.
Returns the root node of the graph.
(graph-provides {:com.wsscode.pathom3.connect.planner/keys [index-attrs]})
Get a set with all provided attributes from the graph.
Get a set with all provided attributes from the graph.
(ignore-nils m)
(inc-snapshot-depth env)
(include-node graph
{:com.wsscode.pathom3.connect.planner/keys [node-id]
:com.wsscode.pathom3.connect.operation/keys [op-name]
:as node})
Add new node to the graph, this add the node and the index of in ::index-syms.
Add new node to the graph, this add the node and the index of in ::index-syms.
(mark-attribute-process-sub-query graph {:keys [key children query]})
Add information about attribute that is present but requires further processing due to subquery, this is created so the runner can quickly know which attributes need to have the subquery processing done.
Add information about attribute that is present but requires further processing due to subquery, this is created so the runner can quickly know which attributes need to have the subquery processing done.
(merge-sibling-resolver-node graph target-node-id source-node-id)
Merges data from source-node-id into target-node-id, them removes the source node.
Merges data from source-node-id into target-node-id, them removes the source node.
(merge-sibling-resolver-nodes graph env parent-node-id node-ids)
(merge-sibling-resolver-nodes* graph pivot node-ids)
(merge-unreachable target-graph
{:com.wsscode.pathom3.connect.planner/keys
[unreachable-paths]})
(merge-unreachable target-graph graph env path)
Copy unreachable attributes from discard-graph to target-graph. Using the extra arity you can also add a new unreachable path in the same call.
Copy unreachable attributes from discard-graph to target-graph. Using the extra arity you can also add a new unreachable path in the same call.
(new-node env node-data)
(next-node-id {:com.wsscode.pathom3.connect.planner/keys [id-counter]})
Return the next node ID in the system, its an incremental number
Return the next node ID in the system, its an incremental number
(node->label node)
Return a string representation for the node, for resolver nodes this is the symbol, branch nodes get AND / OR respectively.
Return a string representation for the node, for resolver nodes this is the symbol, branch nodes get AND / OR respectively.
(node-ancestors graph node-id)
Return all node ancestors. The order of the output will go from closest to farthest nodes, like breathing out of the current node.
Return all node ancestors. The order of the output will go from closest to farthest nodes, like breathing out of the current node.
(node-attribute-provides graph env attr)
For a specific attribute, return a vector containing the provides of each node of that resolver, or the current available data for it.
For a specific attribute, return a vector containing the provides of each node of that resolver, or the current available data for it.
(node-branches node)
Return node branches, which can be the ::run-and or the ::run-or part of the node.
Return node branches, which can be the ::run-and or the ::run-or part of the node.
(node-kind node)
Return a keyword describing the type of the node.
Return a keyword describing the type of the node.
(node-successors graph node-id)
Find successor nodes of node-id, node-id is included in the list. This will add branch nodes before run-next nodes. Returns a lazy sequence that traverse the graph as items are requested.
Find successor nodes of node-id, node-id is included in the list. This will add branch nodes before run-next nodes. Returns a lazy sequence that traverse the graph as items are requested.
(node-with-resolver-config graph env node-id)
Get the node plus the resolver config, when the node has an op-name. If node is not a resolver not it returns nil.
Get the node plus the resolver config, when the node has an op-name. If node is not a resolver not it returns nil.
(optimize-AND-branches graph env node-id)
(optimize-AND-ORs graph _env sibling-ids _parent-id)
(optimize-AND-resolver-siblings graph env parent-id pivot other-nodes)
(optimize-AND-resolvers-pass graph env sibling-ids parent-id)
This pass will collapse the same resolver node branches. This also do a local optimization on AND's and OR's sub-nodes. This is important to simplify the pass to merge OR nodes.
This pass will collapse the same resolver node branches. This also do a local optimization on AND's and OR's sub-nodes. This is important to simplify the pass to merge OR nodes.
(optimize-branch-items graph env branch-node-id)
(optimize-dynamic-resolver-chain graph env node-id)
Merge node and its run-next, when they are the same dynamic resolver.
Merge node and its run-next, when they are the same dynamic resolver.
(optimize-dynamic-resolver-chain?
graph
{:com.wsscode.pathom3.connect.operation/keys [op-name]
:com.wsscode.pathom3.connect.planner/keys [run-next]})
(optimize-graph graph env)
(optimize-node graph env node-id)
(optimize-OR-branches graph env node-id)
(plan-mutation graph env {:keys [key] :as ast})
(plan-mutation-nested-query graph env {:keys [key] :as ast})
(promote-foreign-ast-children
{:com.wsscode.pathom3.connect.planner/keys [foreign-ast] :as ast})
Moves the children from foreign ast to the main children. Also removes the foreign ast attribute.
Moves the children from foreign ast to the main children. Also removes the foreign ast attribute.
(remove-branch-node-parents graph node-id)
When node-id is a branch node, remove all node-parents associated from its children.
When node-id is a branch node, remove all node-parents associated from its children.
(remove-from-parent-branches graph
{:com.wsscode.pathom3.connect.planner/keys
[node-id node-parents]})
Disconnect a branch node from its parents.
Disconnect a branch node from its parents.
(remove-node graph node-id)
Remove a node from the graph. In case of resolver nodes it also removes them from the ::index-syms and after node references.
Remove a node from the graph. In case of resolver nodes it also removes them from the ::index-syms and after node references.
(remove-node* graph node-id)
Remove a node from the graph. Doesn't remove any references, caution!
Remove a node from the graph. Doesn't remove any references, caution!
(remove-node-edges graph node-id)
Remove all node connections. This disconnect the nodes from parents and run-next.
Remove all node connections. This disconnect the nodes from parents and run-next.
(remove-node-expects-index-attrs graph node-id)
Since the node has attribute indexes associated with it, this removes those links considering the attributes listed on expects.
Since the node has attribute indexes associated with it, this removes those links considering the attributes listed on expects.
(remove-node-parent graph node-id node-parent-id)
(remove-root-node-cluster graph node-ids)
Remove a complete node cluster, starting from some node root.
Remove a complete node cluster, starting from some node root.
(reset-env env)
Restore the original environment sent to run-graph! Use this for nested graphs that need a clean environment.
Restore the original environment sent to run-graph! Use this for nested graphs that need a clean environment.
(resolvers-missing-optionals
{:com.wsscode.pathom3.connect.planner/keys [available-data] :as env}
resolvers)
Merge the optionals from a collection of resolver symbols.
Merge the optionals from a collection of resolver symbols.
(runner-node-sym env resolver-name)
Find the runner symbol for a resolver, on normal resolvers that is the resolver symbol, but for foreign resolvers it uses its ::p.c.o/dynamic-name.
Find the runner symbol for a resolver, on normal resolvers that is the resolver symbol, but for foreign resolvers it uses its ::p.c.o/dynamic-name.
(set-node-expects graph node-id expects)
Set node expects, this also removes previous references from index-attrs and add new ones for the new expects.
Set node expects, this also removes previous references from index-attrs and add new ones for the new expects.
(set-node-run-next graph run-next)
(set-node-run-next graph target-node-id run-next)
Set the node run next value and add the node-parent counter part. Noop if target and run next are the same node.
Set the node run next value and add the node-parent counter part. Noop if target and run next are the same node.
(set-node-run-next* graph node-id run-next)
Update the node-id run-next value, if run-next is nil the attribute will be removed from the map.
Update the node-id run-next value, if run-next is nil the attribute will be removed from the map.
(set-node-source-for-attrs graph env)
(set-node-source-for-attrs graph
{:com.wsscode.pathom3.attribute/keys [attribute]}
node-id)
(set-root-node graph node-id)
(shape-reachable? env available shape)
Given an environment, available data and shape, determines if the whole shape is reachable (including nested dependencies).
Given an environment, available data and shape, determines if the whole shape is reachable (including nested dependencies).
(simplify-branch-node graph env node-id)
When a branch node contains a single branch out, remove the AND node and put that single item in place.
Note in case the branch has a run-next, that run-next gets moved to the end of chain to retain the same order as it would run with the branch.
When a branch node contains a single branch out, remove the AND node and put that single item in place. Note in case the branch has a run-next, that run-next gets moved to the end of chain to retain the same order as it would run with the branch.
(transfer-node-indexes graph target-node-id source-node-id)
(transfer-node-parent graph target-node-id source-node-id node-id)
Transfer the node parent from source node to target node. This function will also update the parents references to point to target node.
Transfer the node parent from source node to target node. This function will also update the parents references to point to target node.
(transfer-node-parents graph target-node-id source-node-id)
Transfer node parents from source node to target node. In case source node is root, the root will be transferred to target node.
Transfer node parents from source node to target node. In case source node is root, the root will be transferred to target node.
(update-node graph node-id k f)
(update-node graph node-id k f v)
(update-node graph node-id k f v v2)
(update-node graph node-id k f v v2 v3)
(update-node graph node-id k f v v2 v3 & args)
Update a given node in a graph, like Clojure native update.
Update a given node in a graph, like Clojure native update.
(with-plan-cache env)
(with-plan-cache env cache*)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close