graphql 2021-06-28

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

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

So like this:

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

๐Ÿ‘ 1

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 ๐Ÿ˜‰