Skip to content

Commit

Permalink
Fix pf.eql/map-select case on map container at query
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Oct 29, 2023
1 parent f8146cf commit 5a8f3d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Fix placeholders using different parameters
- 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

## [2023.08.22-alpha]
- BREAKING: `::p.error/missing-output` is now converged to `::p.error/attribute-missing` (issue #149)
Expand Down
5 changes: 3 additions & 2 deletions src/main/com/wsscode/pathom3/format/eql.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
(or (= '... query) (int? query)))

(defn map-select-entry
[env source {:keys [key query type] :as ast}]
[env source {:keys [key query type params] :as ast}]
(if-let [x (find source key)]
(let [val (val x)
ast (if (recursive-query? query) (:parent-ast ast) ast)
Expand All @@ -112,7 +112,8 @@
val

(map? val)
(if (-> val meta :com.wsscode.pathom3.connect.runner/map-container?)
(if (or (-> val meta :com.wsscode.pathom3.connect.runner/map-container?)
(-> params :com.wsscode.pathom3.connect.runner/map-container?))
(into (with-meta {} (meta val))
(map (fn [entry]
(coll/make-map-entry
Expand Down
9 changes: 8 additions & 1 deletion test/com/wsscode/pathom3/format/eql_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@
:y {:a 3 :b 4}}}
[{:foo [:b]}])
{:foo {:x {:b 2}
:y {:b 4}}})))
:y {:b 4}}}))

(testing "from query"
(is (= (pf.eql/map-select {} {:foo {:x {:a 1 :b 2}
:y {:a 3 :b 4}}}
[{'(:foo {::pcr/map-container? true}) [:b]}])
{:foo {:x {:b 2}
:y {:b 4}}}))))

(testing "recursive query"
(is (= (pf.eql/map-select {}
Expand Down

0 comments on commit 5a8f3d7

Please sign in to comment.