Skip to content

Commit

Permalink
When planning placeholders, skip parameterized attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Aug 24, 2024
1 parent bd87f38 commit 671b263
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/main/com/wsscode/pathom3/connect/planner.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,9 @@
index-ast
(coll/filter-vals (comp seq :children) (pf.eql/index-ast placeholder-ast))))

(defn remove-parameterized-attributes [ast]
(eql/transduce-children (remove #(seq (:params %))) ast))

(defn compute-non-index-attribute
"This function deals with attributes that are not part of the index execution. The
cases here are:
Expand Down Expand Up @@ -1617,7 +1620,7 @@
(-> (add-placeholder-entry graph attr)
(cond->
(empty? (:params ast))
(-> (compute-run-graph* env)
(-> (compute-run-graph* (update env :edn-query-language.ast/node remove-parameterized-attributes))
(update ::index-ast merge-placeholder-ast ast))))))

(defn plan-mutation-nested-query [env {:keys [key] :as ast}]
Expand Down
11 changes: 5 additions & 6 deletions test/com/wsscode/pathom3/connect/runner_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2927,11 +2927,10 @@
:y 20}))))

(deftest run-graph!-placeholders-test
(is (graph-response? (pci/register (pbir/constantly-resolver :foo "bar"))
{}
[{:>/path [:foo]}]
{:foo "bar"
:>/path {:foo "bar"}}))
(is (check-serial (pci/register (pbir/constantly-resolver :foo "bar"))
{}
[{:>/path [:foo]}]
{:>/path {:foo "bar"}}))

(is (graph-response? (pci/register (pbir/constantly-resolver :foo "bar"))
{:foo "baz"}
Expand Down Expand Up @@ -3021,7 +3020,7 @@
{:>/m3 [(:y {:m 3})]}
{:>/m4 [(:y {:m 4})]}]
{:x 10
:y 30
:y 20
:>/m2 {:x 10
:y 20}
:>/m3 {:x 10
Expand Down

0 comments on commit 671b263

Please sign in to comment.