Hello GraphQL/Lacinia developers, whats the best approach to coerce inputs for graphql endpoint. I need to coerce string to uuid. so that datomic can understand it. Currently I wrote his wrapper, which I wrap for each handler where id is used. But this feels hacky. Any tips
(defn uuid-wrapper [handler]
(fn [context {:keys [id] :as args} entity]
(if id
(if (uuid? (u/str->uuid id))
(let [args (assoc args :id (u/str->uuid id))]
(handler context args entity))
nil)
(handler context args entity))))
You could define a UUID
scalar type which could convert input strings to UUIDs and vice-versa.
Not sure how I can do that. Can you please provide an example 🙂
Nevermind, found the doc https://lacinia.readthedocs.io/en/latest/custom-scalars.html
Boy, this federation stuff is a little brain bending.