Skip to content

Commit

Permalink
Always unparse on call types
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkerlucio committed Sep 3, 2017
1 parent bc1c30f commit b888b86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/om/next/impl/parser.cljc
Expand Up @@ -154,7 +154,9 @@
(let [key (if (= :call type) (parameterize key params) key)]
(if (or (= :join type)
(and (= :call type) (:children ast)))
(if (and (not= '... query) (not (number? query)) (true? unparse?))
(if (and (not= '... query) (not (number? query))
(or (true? unparse?)
(= :call type)))
(let [{:keys [children]} ast]
(if (and (== 1 (count children))
(= :union (:type (first children)))) ;; UNION
Expand Down
7 changes: 7 additions & 0 deletions src/test/om/next/tests.cljc
Expand Up @@ -1013,6 +1013,13 @@
(is (= @ret {:bar 43}))
(is (nil? (meta @ret)))))

(deftest test-mutate-ast-children
(let [p (om/parser {:mutate
(fn [{:keys [ast]} _ _]
{:remote (assoc ast :children (:children (om/query->ast [:id])))})})]
(is (= (p {} `[(do-something {:foo "bar"})] :remote)
`[{(do-something {:foo "bar"}) [:id]}]))))

;; -----------------------------------------------------------------------------
;; Edge cases

Expand Down

0 comments on commit b888b86

Please sign in to comment.