This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-04
Channels
- # announcements (5)
- # aws (11)
- # babashka (15)
- # beginners (101)
- # biff (14)
- # calva (45)
- # clj-kondo (18)
- # cljs-dev (5)
- # clojure (178)
- # clojure-austin (5)
- # clojure-europe (8)
- # clojure-france (1)
- # clojure-nl (12)
- # clojure-norway (6)
- # clojure-spec (4)
- # clojure-uk (1)
- # clojurescript (13)
- # community-development (2)
- # conjure (6)
- # cursive (8)
- # datahike (1)
- # datalevin (3)
- # datascript (36)
- # datomic (6)
- # emacs (2)
- # etaoin (2)
- # fulcro (5)
- # graalvm (6)
- # gratitude (3)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # lsp (19)
- # malli (4)
- # nbb (11)
- # off-topic (4)
- # other-languages (1)
- # pathom (19)
- # pedestal (1)
- # shadow-cljs (22)
- # spacemacs (16)
- # tools-deps (31)
- # vim (7)
but i don't think that it make sense for EQL's. I would classify as a "undefined behavior"
Is it bad form, even if technically possible?
Ah, got it. Thought so.
So if you want to run a bunch of mutations in series you just make a regular function that just calls p.eql/process
on different mutation vectors or just use one vector with multiple mutations if there is no logic to perform between mutations, right?
I was thinking either:
(p.eql/process env [(create-user {}) (login-user {})])
or
(p.eql/process env [(create-user {})])
;; use result from first mutation somehow
(p.eql/process env [(login-user {})])
you can reuse at funciton level.
What the frontend will do if [(create-user) (login)]
fail?
it will test to see if it failed at create-user
or at login
?
then decide if will repeat both of just one?
I see your point.
Hmm, defmutation
is just a wrapper around defresolver
, right? In that case, I guess mutations can be called as regular functions the same way resolvers can? https://pathom3.wsscode.com/docs/resolvers/#invoking-resolvers
being on the server, you can even do things like this:
(defmutation create-user-and-login [ctx params]
(let []
(sql/with-rollback
(p.eql/process ctx `[(create-user ~params)])
(p.eql/process ctx `[(login ~params)]))))
But I agree with you, that calling the mutation directly should be better, to avoid huge stacktraces.Yes, I guess if you use the mutation as a function you skip Pathom's tree traversal and accompanying trace in case of an error. Good point.
one thing to consider if you call the mutation directly is that you also dont get the mutation join processing (if you have a query to run over the mutation response)
Thanks @U066U8JQJ, I hadn't considered that. Seems like a fair tradeoff to make in some cases. Good set of options here.
yeah, calling the mutation directly is really just like calling a regular fn, with a fixed interface (`env params`)
its a convenience, and if your usage makes sense, go for it 🙂