Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use query error formatting fn in query error coercion #12

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:deps {org.clojure/clojure {:mvn/version "1.11.1"}
org.clojure/core.async {:mvn/version "1.6.681"}
com.fluree/db {:git/url "https://github.com/fluree/db.git"
:git/sha "a9cbf41c355ac7415239fa37e6eb3790faad15b0"}
:git/sha "310e71e0175302660f8312f1410173e2b63c66a3"}
com.fluree/json-ld {:git/url "https://github.com/fluree/json-ld.git"
:git/sha "2b4a4cf75f2b823eea7fa221c6b9cbeb68299e90"}

Expand Down Expand Up @@ -29,7 +29,8 @@
info.sunng/ring-jetty9-adapter ^{:antq/exclude "0.30.x"} {:mvn/version "0.22.2"}
metosin/reitit {:mvn/version "0.6.0"}
metosin/muuntaja {:mvn/version "0.6.8"}
metosin/malli {:mvn/version "0.13.0"}
metosin/malli {:git/url "https://github.com/metosin/malli.git"
:git/sha "5211aca498ff7b022c36de4ca713990f5e731a9c" }
ring-cors/ring-cors {:mvn/version "0.1.13"}

;; retries
Expand Down
13 changes: 12 additions & 1 deletion src/fluree/server/components/http.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[fluree.db.json-ld.credential :as cred]
[fluree.db.json-ld.transact :as transact]
[fluree.db.util.log :as log]
[fluree.db.validation :as v]
[fluree.server.handlers.ledger :as ledger]
[fluree.server.handlers.create :as create]
[fluree.server.handlers.remote-resource :as remote]
Expand Down Expand Up @@ -75,7 +76,7 @@

(def FqlQuery (m/schema [:and
[:map-of :keyword :any]
(fql/query-schema [[:from LedgerAlias]])]
(fql/query-schema [])]
{:registry fql/registry}))

(def SparqlQuery (m/schema :string))
Expand Down Expand Up @@ -137,12 +138,21 @@
{:port (ds/ref [:env :http/server :port])
:join? false}}})

(def query-coercer
(reitit.coercion.malli/create
{:strip-extra-keys false
:error-keys #{}
:encode-error (fn [explained]
{:error :db/invalid-query
:message (v/format-explained-errors explained nil)})}))

(def query-endpoint
{:summary "Endpoint for submitting queries"
:parameters {:body QueryRequestBody}
:responses {200 {:body QueryResponse}
400 {:body ErrorResponse}
500 {:body ErrorResponse}}
:coercion ^:replace query-coercer
:handler #'ledger/query})


Expand All @@ -152,6 +162,7 @@
:responses {200 {:body HistoryQueryResponse}
400 {:body ErrorResponse}
500 {:body ErrorResponse}}
:coercion ^:replace query-coercer
:handler #'ledger/history})

(defn wrap-assoc-system
Expand Down
2 changes: 1 addition & 1 deletion src/fluree/server/handlers/ledger.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
did (assoc :did did)))
query* (if opts (assoc query :opts opts) query)]
{:status 200
:body (deref! (fluree/from-query conn query* {:format format}))}))
:body (deref! (fluree/query-connection conn query* {:format format}))}))

(defhandler history
[{:keys [fluree/conn credential/did]
Expand Down
Loading