Fork me on GitHub

I’m trying to use directives for authentication purpose. Has anybody ever tried this using lacinia?

Lennart Buit09:06:26

Well kinda, we have a @possibleTypes directive (like GH also has) and we have a function that wraps a lacinia resolver fn and checks those types / if all is right calls the actual resolver.. But there is nothing automatic here, you really need to remember to wrap your resolver

Lennart Buit09:06:01

So like this:

(defn with-possible-type-check
  (fn [ctx args val]
     (if (possible-types-correct? ctx args val)
       (resolver-fn ctx args val)
       (resolve-as nil {:message "Nope"}))))

👍 2
Lennart Buit09:06:22

Here be dragons tho, in possible-types-correct? we navigate the parsed directives in ctx, that isn’t promised to be stable, so breaking is on us 😉