Skip to content

Instantly share code, notes, and snippets.

@wilkerlucio
Created July 30, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilkerlucio/c3c76024da0807223592cdd5bcd71d0e to your computer and use it in GitHub Desktop.
Save wilkerlucio/c3c76024da0807223592cdd5bcd71d0e to your computer and use it in GitHub Desktop.
Example of Pathom with Fulcro 3
(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