adding more validation.

This commit is contained in:
BC
2018-07-31 17:55:57 -07:00
parent 271185690a
commit 2cc193a66f
5 changed files with 18 additions and 9 deletions

View File

@@ -16,9 +16,14 @@
(when (= "none" (:role (:identity r)))
(throw-unauthorized))
(let [variables (some-> (query-params "variables")
edn/read-string)]
{:status 200
:body (pr-str (ql/query (:identity r) (query-params "query") variables ))
:headers {"Content-Type" "application/edn"}})))
(try
(let [variables (some-> (query-params "variables")
edn/read-string)]
{:status 200
:body (pr-str (ql/query (:identity r) (query-params "query") variables ))
:headers {"Content-Type" "application/edn"}})
(catch Exception e
{:status 400
:body (pr-str {:data (merge {:message (.getMessage e)} (ex-data e))})
:headers {"Content-Type" "application/edn"}}))))
wrap-secure))