Last active
November 1, 2022 16:18
-
-
Save mdemare/0e1671bba9c664bde085c0472604507d to your computer and use it in GitHub Desktop.
Normal function, wrap using partial or anonymous function at caller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn load-entities | |
[f loader {:keys [::ooapi/type] :as request}] | |
(if (= "relation" type) | |
(f request) | |
(when-result [entity (loader request) | |
offerings (load-offerings loader request) | |
education-specification (if (= type "education-specification") | |
entity | |
(loader (assoc request | |
::ooapi/type "education-specification" | |
::ooapi/id (ooapi/education-specification-id entity))))] | |
(f (assoc request | |
::ooapi/entity (assoc entity :offerings offerings) | |
::ooapi/education-specification education-specification))))) | |
;; either call via partial | |
(let [ooapi-loader (make-ooapi-http-loader gateway-root-url gateway-credentials) | |
handle-updated (as-> updated-handler/update-mutation f | |
(updated-handler/wrap-resolver f resolver) | |
(partial load-entities f (validating-loader ooapi-loader)))] | |
..) | |
;; or anonymous function | |
(let [ooapi-loader (make-ooapi-http-loader gateway-root-url gateway-credentials) | |
handle-updated (as-> updated-handler/update-mutation f | |
(updated-handler/wrap-resolver f resolver) | |
#(wrap-load-entities f (validating-loader ooapi-loader) %))] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment