Skip to content

Commit

Permalink
Fix wrong input order on nested resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Aug 23, 2024
1 parent 30462f3 commit b8ea325
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Idents run in parallel when using parallel processor (issue #208)
- Fix wrong input order on nested resolvers (issue #205)
- Fix `pf.eql/map-select` case on map container at query
- Merge params when merging nodes on planner (issue #216)

## [2023.08.22-alpha]
- BREAKING: `::p.error/missing-output` is now converged to `::p.error/attribute-missing` (issue #149)
Expand Down
6 changes: 6 additions & 0 deletions src/main/com/wsscode/pathom3/connect/planner.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@
(defn combine-expects [na nb]
(update na ::expects pfsd/merge-shapes (::expects nb)))

(defn combine-params [na nb]
(cond-> na
(or (::params na) (::params nb))
(update ::params merge (::params nb))))

(defn combine-inputs [na nb]
(if (::input nb)
(update na ::input pfsd/merge-shapes (::input nb))
Expand Down Expand Up @@ -809,6 +814,7 @@
(-> graph
; merge any extra keys from source node, but without overriding anything
(update-node target-node-id nil coll/merge-defaults source-node)
(update-node target-node-id nil combine-params source-node)
(update-node target-node-id nil combine-expects source-node)
(update-node target-node-id nil combine-inputs source-node)
(update-node target-node-id nil combine-foreign-ast source-node)
Expand Down
19 changes: 18 additions & 1 deletion test/com/wsscode/pathom3/connect/planner_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,24 @@
::pcp/input {}
::pcp/node-id 1
::pcp/params {:x 1}}}
::pcp/root 1})))))
::pcp/root 1}))))

(testing "params should merge when different attributes are related to same node call"
(is (= (compute-run-graph
{::resolvers [{::pco/op-name 'a
::pco/output [:a :b]}]
::eql/query [(list :a {:x "y"}) (list :b {:z "foo"})]})
'{:com.wsscode.pathom3.connect.planner/nodes {1 {:com.wsscode.pathom3.connect.operation/op-name a,
:com.wsscode.pathom3.connect.planner/expects {:a {}, :b {}},
:com.wsscode.pathom3.connect.planner/input {},
:com.wsscode.pathom3.connect.planner/node-id 1,
:com.wsscode.pathom3.connect.planner/params {:x "y", :z "foo"}}},
:com.wsscode.pathom3.connect.planner/index-ast {:a {:type :prop, :dispatch-key :a, :key :a, :params {:x "y"}},
:b {:type :prop, :dispatch-key :b, :key :b, :params {:z "foo"}}},
:com.wsscode.pathom3.connect.planner/user-request-shape {:a {}, :b {}},
:com.wsscode.pathom3.connect.planner/index-resolver->nodes {a #{1}},
:com.wsscode.pathom3.connect.planner/index-attrs {:a #{1}, :b #{1}},
:com.wsscode.pathom3.connect.planner/root 1}))))

(deftest compute-run-graph-optimize-test
(testing "optimize AND nodes"
Expand Down

0 comments on commit b8ea325

Please sign in to comment.