Created
July 30, 2020 14:03
-
-
Save wilkerlucio/c3c76024da0807223592cdd5bcd71d0e to your computer and use it in GitHub Desktop.
Example of Pathom with Fulcro 3
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 pathom-remote [parser] | |
{:transmit! (fn transmit! [_ {::txn/keys [ast result-handler]}] | |
(let [edn (eql/ast->query ast) | |
ok-handler (fn [result] | |
(try | |
(result-handler (assoc result :status-code 200)) | |
(catch :default e | |
(js/console.error e "Result handler for remote failed with an exception.")))) | |
error-handler (fn [error-result] | |
(try | |
(result-handler (merge error-result {:status-code 500})) | |
(catch :default e | |
(js/console.error e "Error handler for remote failed with an exception."))))] | |
(go | |
(try | |
(ok-handler {:transaction edn :body (<?maybe (parser {} edn))}) | |
(catch :default e | |
(js/console.error "Pathom Remote error:" e) | |
(error-handler {:body e}))))))}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment