pathom3 icon indicating copy to clipboard operation
pathom3 copied to clipboard

Params for multiple instances of foreign resolver don't get merged properly

Open jacobobryant opened this issue 11 months ago • 1 comments

I'm using the graphql integration and did a query like [(:foreign-resolver {:a 1}) :local-resolver], where :local-resolver includes :foreign-resolver in its input. When :local-resolver was included in the query, the params weren't passed to :foreign-resolver. I tracked the issue down to pf.eql/merge-ast-children, which was being called by combine-foreign-ast. ~This fixed the issue~ (UPDATE: it caused other problems though):

diff --git a/src/main/com/wsscode/pathom3/format/eql.cljc b/src/main/com/wsscode/pathom3/format/eql.cljc
index 8726cee..e63f4a3 100644
--- a/src/main/com/wsscode/pathom3/format/eql.cljc
+++ b/src/main/com/wsscode/pathom3/format/eql.cljc
@@ -304,14 +304,18 @@
                      (update idx key merge-ast-children node)
                      (assoc idx key node))))
                idx
-               (:children ast2))]
+               (:children ast2))
+        params (merge (:params ast1) (:params ast2))]
     (-> (or ast1 ast2)
         (cond->
           (seq idx')
           (assoc :children (map-children->children idx'))
 
           (and (seq idx') (not (contains? #{:join :root} (:type ast1))))
-          (assoc :type :join))
+          (assoc :type :join)
+
+          (seq params)
+          (assoc :params params))
         (dissoc :query))))
 
 (defn merge-asts

Let me know if more info/setting up a PR/etc would be helpful.

jacobobryant avatar Dec 14 '24 00:12 jacobobryant