Fork me on GitHub
Vishal Gautam15:09:43

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))
      (handler context args entity))))


You could define a UUID scalar type which could convert input strings to UUIDs and vice-versa.

Vishal Gautam16:09:11

Not sure how I can do that. Can you please provide an example 🙂


Boy, this federation stuff is a little brain bending.