This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-14
Channels
- # aleph (2)
- # announcements (11)
- # aws (4)
- # babashka (42)
- # babashka-sci-dev (81)
- # beginners (90)
- # biff (2)
- # calva (40)
- # cider (16)
- # clj-kondo (26)
- # clj-on-windows (1)
- # cljdoc (4)
- # cljfx (1)
- # cljsrn (2)
- # clojure (92)
- # clojure-austin (2)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-uk (3)
- # clojured (3)
- # clojurescript (19)
- # community-development (3)
- # conjure (1)
- # cursive (4)
- # datalevin (3)
- # datomic (5)
- # emacs (13)
- # events (1)
- # fulcro (26)
- # graphql (1)
- # hugsql (15)
- # introduce-yourself (5)
- # leiningen (1)
- # lsp (29)
- # minecraft (19)
- # music (1)
- # off-topic (36)
- # pathom (12)
- # podcasts-discuss (2)
- # portal (8)
- # re-frame (12)
- # reagent (11)
- # rewrite-clj (4)
- # shadow-cljs (56)
- # spacemacs (2)
- # vim (12)
- # windows (3)
- # xtdb (43)
Hi @wilkerlucio, I'm having some params-related problem and I'm not sure what is causing it. I have a resolver that is expecting some params sent up by fulcro, and when I checked (-> env :ast :params)
it is nil despite the param was sent up normally. I'll put the code snippets in this thread for illustration.
Parser:
(p/parser {::p/env {::p/reader [p/map-reader pc/reader2 pc/ident-reader pc/index-reader]
::p/process-error process-error
::pc/mutation-join-globals [:tempids]}
::p/mutate pc/mutate
::p/plugins [(pc/connect-plugin {::pc/register resolvers})
p/error-handler-plugin
p/trace-plugin
;; FIXME: Seems to be fired twice
(p/post-process-parser-plugin (fn [output]
(let [output (-> output p/elide-not-found p/raise-errors)]
(if-let [errors (::p/errors output)]
errors
output))))]})
Resolver:
(defresolver bookmarks-resolver
[{{user-id :user/id} :request :as env} {:tab/keys [id] :as input}]
{::pc/input #{:tab/id}
::pc/output [{:tab/bookmarks bookmark-output}]}
...)
[({[:tab/id #uuid "bc1599de-e58a-4d3b-b61b-b0e50b6a2749"]
[{:tab/bookmarks
[:bookmark/id
:bookmark/title
:bookmark/url
:bookmark/favourite
:bookmark/image
:bookmark/tab-id
{:bookmark/tags [:tag/id :tag/name :tag/colour]}]}]}
{:tab/password "v"})]
As you can see I'm sending up :tab/password
but it doesn't exist in (-> env :ast :params)
the problem here is the param location, because Fulcro injects the params to the ident, not to the attributes, so Pathom has it in a different location than you are expecting. there two ways around it, the most common seems to be to have a plugin to propagate params down, or you have to set the params in the query itself (instead of using the`:params` option from Fulcro)
I dont have it now, but if you ask on #fulcro somebody probably has that code already to give to you
{::p.eql/wrap-process-ast (fn [process] (fn [env ast] (-> (if (:query-params env) env (assoc env :query-params (reduce (fn [qps {:keys [type params] :as x}] (cond-> qps (and (not= :call type) (seq params)) (merge params))) {} (:children ast)))) (process ast))))}
@wilkerlucio Yep indeed a plugin is needed for this. Thank you and @U797MAJ8M for the help. It's working wonderfully now 🙂