Fork me on GitHub

hm the example here: doesn’t seem to work because namespaces like don’t exist

Björn Ebbinghaus13:01:12

Hm. The examples are using fulcro 2 ... This needs to be updated. 😉


@roklenarcic yeah, for F2, I don't have a shared library with that yet, but you can use this (rename the ns to something that makes sense to you):

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

(defn pathom-remote [parser]
  {:transmit! (fn transmit! [_ {::txn/keys [ast result-handler]}]
                (let [edn           (eql/ast->query ast)
                      ok-handler    (fn [result]
                                        (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]
                                        (result-handler (merge error-result {:status-code 500}))
                                        (catch :default e
                                          (js/console.error e "Error handler for remote failed with an exception."))))]
                      (ok-handler {:body (<?maybe (parser {} edn))})
                      (catch :default e
                        (js/console.error "Pathom Remote error:" e)
                        (error-handler {:body e}))))))})


A Small lib to qualify/unqualify data with #pathom Docs still WIP.


I’m trying to dispatch a server-property load! call in fulcro to a pathom resolver with params. the server property seems to be getting picked up properly, but the params I added in the options map of load! don’t seem to be getting parsed by pathom and fed into my resolver as params. any suggestions for how to debug?


There's a Pathom plugin from Fulcro RAD that will fix this. This one is just slightly altered:

(def query-params-to-env-plugin
  "Adds top-level load params to env, so nested parsing layers can see them."
   (fn [parser]
     (fn [env tx]
       (let [children (-> tx eql/query->ast :children)
             query-params (-> (->> children
                                     (fn [qps {:keys [type params] :as x}]
                                       (cond-> qps
                                               (and (not= :call type) (seq params)) (merge params)))
                              (dissoc :pathom/context))
             env (assoc env :query-params query-params)]
         (parser env tx))))})

🙌 8

Then you can pick up the key query-params from in the env of the resolver you want to see your parameters in.