graphql

2021-06-28T05:04:44.034100Z

https://lacinia.readthedocs.io/en/latest/directives.html is there any update on directive topic?

2021-06-28T08:57:32.034700Z

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

2021-06-28T09:41:26.036500Z

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

2021-06-28T09:43:01.038Z

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
2021-06-28T09:46:22.039Z

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