Skip to content

Instantly share code, notes, and snippets.

@mdemare
Last active November 1, 2022 16:17
Show Gist options
  • Save mdemare/388d0d32cfe7e426c83c0e861b74c48f to your computer and use it in GitHub Desktop.
Save mdemare/388d0d32cfe7e426c83c0e861b74c48f to your computer and use it in GitHub Desktop.
Function creating function
(defn wrap-load-entities
[f ooapi-loader]
(let [loader (validating-loader ooapi-loader)]
(fn [{: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)))))))
(let [ooapi-loader (make-ooapi-http-loader gateway-root-url gateway-credentials)
handle-updated (-> updated-handler/update-mutation
(updated-handler/wrap-resolver resolver)
(wrap-load-entities ooapi-loader))]
..)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment