This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-10
Channels
- # announcements (4)
- # beginners (116)
- # boot (4)
- # calva (63)
- # cider (8)
- # clara (20)
- # cljdoc (10)
- # cljsrn (69)
- # clojure (115)
- # clojure-austin (1)
- # clojure-dev (4)
- # clojure-finland (1)
- # clojure-italy (3)
- # clojure-nl (6)
- # clojure-russia (10)
- # clojure-uk (84)
- # clojurescript (28)
- # cursive (14)
- # data-science (1)
- # datascript (1)
- # datomic (11)
- # duct (3)
- # emacs (13)
- # figwheel-main (11)
- # fulcro (4)
- # graphql (6)
- # jackdaw (2)
- # jobs (23)
- # jobs-rus (1)
- # kaocha (11)
- # lein-figwheel (13)
- # leiningen (55)
- # luminus (14)
- # lumo (22)
- # off-topic (121)
- # pathom (19)
- # re-frame (6)
- # reagent (3)
- # reitit (22)
- # remote-jobs (10)
- # ring-swagger (1)
- # shadow-cljs (67)
- # slack-help (5)
- # spacemacs (1)
- # sql (18)
- # vim (28)
- # yada (2)
[{(foo {}) [:bar]}]
cant return {foo [{:bar 1} {:bar 2}]}
. Pathom always suppose that the return of a mutation is a map. Is it intentional?
@souenzzo yup, that's by design, you see that everywhere, inputs must be maps, outputs must be maps, params must be maps, this is all intentional to force things to always compose (allowing extra things) and forces everything to be labelled
yes, but your response data also must be labeled
eg: {:person/id 123}
, in this case 123
is labeled as :person/id
, if it was just 123
, no label
its about context independence, makes sense?
specially if you consider mutation joins, if the mutation return wasn't a map it couldn't be extended
It's a problem with #fulcro. I my component
(fp/defsc Chat [_ _]
{:query [:chat/id
{:chat/msg (fp/get-query Msg)}]
:ident [:chat/id :chat/id]})
Then I have a mutation [(load-older {:msg/id older-msg-id})]
It is called with (fm/returning Msg)
This mutation need to be (df/prepend-to [:chat/id id :chat/msg])
So it generate [{(load-older {}) [:msg/id ...]}]
When I do [{(load-older {}) [{:older [:msg/id ...]}]}]
, but this way, I can't merge correctly in fulcro state
are you using mutations to load data? any reason to don't use fulcro df/load
?
ATM I'm using df/load
But once it will be called by "many" places, I thought that wrap it in a mutation makes sense. It also have some effects: set ui/loading?
true, if returns empty, set final?
true...
fulcro load use the markers, I really suggest you keep using load, you can have wraps around it, but using mutations for data fetching goes off the semantics of the system... but anway, since you are adding multiple items to a list, there is no default helper in fulcro that will save you, when you load a resource its expected it directly maps to whatever component you are loading, but the modal doesn't have anything pre-made for specific injections (add this N items to a list), for those you will need a post-mutation
anyway
for pagination I have some set of helpers that do what you want, but they require post-mutations to be involved
(fm/defmutation merge-page-items [{:keys [abrams.page/items]
::keys [page-key]}]
(action [env]
(db.h/swap-entity! env update-in [page-key :abrams.page/items] #(into items %))))
(defn load-next-page [this {::keys [page-key load-config]}]
(let [ref (fp/get-ident this)
state (-> (fp/get-reconciler this) fp/app-state)
cursor (-> (fp/props this) page-key :abrams.page/next-cursor)
current-items (get-in @state (conj ref page-key :abrams.page/items))
load (merge {:query [{ref [(-> (fp/get-query this)
(fp/focus-query [page-key])
first
(list {:abrams.page/cursor cursor}))]}]
:post-mutation `merge-page-items
:post-mutation-params {:abrams.page/items current-items
::page-key page-key}}
load-config)]
(fp/transact! this [(list 'fulcro/load load)])))
com.wsscode.fulcro.db-helpers
is on workspace
dir. It not public (i think that can be)
But I'm having progress. tnks
that db-helpers are internal on our project to be honest, but most of it is already ported in incubator 😉
something like this ^^^^
in my case all paginations use the :abrams.page/items
standard, this way I can write generic pagination components that work across many different resources