fix(api): returns of raw datascript query (#6568)

* fix(api): returns of raw datascript query

Co-authored-by: Andelf <andelf@gmail.com>
pull/6572/head
Charlie 2022-09-02 13:22:29 +08:00 committed by GitHub
parent 8dd0e1977c
commit 3c72670243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -41,14 +41,19 @@
;; helpers
(defn- normalize-keyword-for-json
[input]
(when input
(walk/postwalk
([input] (normalize-keyword-for-json input true))
([input camel-case?]
(when input
(walk/postwalk
(fn [a]
(cond
(keyword? a) (csk/->camelCase (name a))
(keyword? a)
(cond-> (name a)
camel-case?
(csk/->camelCase))
(uuid? a) (str a)
:else a)) input)))
:else a)) input))))
(defn- parse-hiccup-ui
[input]
@ -735,7 +740,7 @@
(let [query (cljs.reader/read-string query)
resolved-inputs (map (comp query-react/resolve-input cljs.reader/read-string) inputs)
result (apply d/q query db resolved-inputs)]
(clj->js result)))))
(bean/->js (normalize-keyword-for-json result false))))))
(defn ^:export custom_query
[query-string]