How to prioritize paths? #57
mauricioszabo
started this conversation in
Ideas
Replies: 1 comment 4 replies
-
By the way, I forgot to tell that I could reasonably solve the prioritization problem by using this as a (defn prioritize [{::pcp/keys [graph] :as env} or-node node-ids]
(let [expects (-> or-node :com.wsscode.pathom3.connect.planner/expects keys)
nodes (for [id node-ids
parent (pcp/node-successors graph id)
:let [config (pcp/node-with-resolver-config graph env parent)
provides (:com.wsscode.pathom3.connect.operation/provides config)]
:when (and provides (every? provides expects))]
[id config])
[id] (apply max-key #(-> % second (::pco/priority 0)) nodes)]
(or id (first node-ids)))) I'll keep testing to see if this solves my problem |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently having trouble with priorization. In my case, I'm trying to resolve an output that have two different paths, both with different priorizations. So, in my case, what I have is:
a
->b
->c
(c
have priority0
,b
have priority2
)a
->c
(c
have priority1
)In this case, Pathom makes the first graph of prioritizations
[0 2 0
] and the second[0 1]
, and when it sorts it chose the first path. This is mostly likely what we don't want to happen.But, is there any "rule" that we can chose so that prioritization works? I thought that maybe we could the sorting use the resolver output like:
And then sort accordingly (so, it'll try to get the "right" priorities by checking if that output exist on other paths, and if it does, which one have greater priority, and chose correctly). But as Pathom can have multiple outputs, this becomes not so clear in other cases, and also it's not clear what to do if both paths have intermediary steps that do not appear on others.
Suggestions?
Beta Was this translation helpful? Give feedback.
All reactions