Fork me on GitHub
#pathom
<
2020-03-12
>
Björn Ebbinghaus11:03:27

com.wsscode.pathom.fulcro.network
is depending on fulcro 2 Is there a way to use pathom on the client with fulcro 3?

wilkerlucio17:03:30

@mroerni yes, but you have to implement, its quite simple, here is an example:

(ns pathom-remote-fulcro3
  (:require [com.fulcrologic.fulcro.algorithms.tx-processing :as txn]
            [com.wsscode.async.async-cljs :refer [go-promise <?maybe]]
            [edn-query-language.core :as eql]))

(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-promise
         (try
           (ok-handler {:body (<?maybe (parser {} edn))})
           (catch :default e
             (js/console.error "Pathom Remote error:" e)
             (error-handler {:body e}))))))})

❤️ 4
myguidingstar18:03:37

@wilkerlucio a dynamic resolver is one that doesn't have fixed input and output. What does ::pc/provides of such resolver look like? What about oir and io indexes for dynamic resolvers?

wilkerlucio19:03:01

there is no output or provides on dynamic resolvers (in the new model) in the past there was a ::pc/compute-output, but that's not used in the new reader. what matters is how you build the index to point to this resolvers, Pathom will try to accumulate all the calls for that and run a single one

wilkerlucio19:03:21

there is some things to figure still, if you look at how pathom is dealing with foreign parsers, its another example of how dynamic resolvers work

myguidingstar19:03:57

another question: why the code here throw exception if ::pc/output is not specified? https://gist.github.com/myguidingstar/06d912afb73087bba6b3a01abf7e9db8 (Though the pathom-datomic resolver still doesn't have ::pc/output!!!)

wilkerlucio19:03:48

what exactly throws that? is this some spec validation? it should not require it

myguidingstar09:03:35

{:a/x :com.wsscode.pathom.core/reader-error, :com.wsscode.pathom.core/errors {[:a/x] "class clojure.lang.ExceptionInfo: No output available - #:com.wsscode.pathom.connect{:sym dev/my-resolver}"}}

myguidingstar09:03:00

the result if I comment out the line ::pc/output []

otwieracz21:03:28

Hey, where can I find any information how to build Pathom API on top of Ring?

otwieracz21:03:48

(just like with Fulcro, but I'd like to try using it without it)

wilkerlucio21:03:21

@slawek098 the parser is just a function, in any case the work is about reading the EQL query somehow (usually on the POST body), pass that to the parser and encode the response

otwieracz21:03:23

Yes, I started to wrap it on my own.

otwieracz21:03:26

Seems like it's working.

otwieracz21:03:38

Should be at least. Now I need to ask some transit queries from frontend.

sheluchin22:03:53

I'm trying to better understand how to use Walkable. Do I still need to explicitly define resolvers which wrap parser calls, or is Walkable abstracting that away?