@tlonist.sang
I've done something similar, making use of the :apply-field-directives
option on schema/compile.
This isn't the exact code but it basically goes like this
(schema/compile schema {:apply-field-directives (fn [field field-resolver]
(let [directives (:directives field)
required-scopes (->> directives
(filter #(= :required-scope (:directive-type %)))
(map (comp :scope :directive-args))
distinct
seq)]
(fn [{:keys [user] :as ctx} args parent]
(if (has-scopes? user required-scopes)
(field-resolver ctx args parent)
(throw auth-error)))))})
It's a bit more automatic than manually wrapping each resolverit was kind of hard to track down that option, I expected to find it on the page you linked, but came across it here https://walmartlabs.github.io/apidocs/lacinia/com.walmartlabs.lacinia.schema.html so I assume it's considered 'supported'
cool. this can be a workaround! I think the documentation needs a lot more update.. it’s frustrating when the only source of truth is lacking in content.
Oh nice, I didn’t know of that option either