This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-12
Channels
- # announcements (1)
- # babashka (42)
- # beginners (114)
- # bristol-clojurians (2)
- # calva (7)
- # cider (4)
- # clj-kondo (7)
- # cljs-dev (37)
- # cljsrn (13)
- # clojure (114)
- # clojure-austin (3)
- # clojure-europe (5)
- # clojure-nl (10)
- # clojure-spec (77)
- # clojure-sweden (4)
- # clojure-uk (16)
- # clojurescript (52)
- # conjure (155)
- # core-async (18)
- # cursive (23)
- # datomic (20)
- # duct (2)
- # emacs (13)
- # figwheel (3)
- # figwheel-main (9)
- # fulcro (31)
- # gis (8)
- # helix (33)
- # jobs (12)
- # jobs-discuss (66)
- # kaocha (4)
- # lein-figwheel (1)
- # meander (16)
- # off-topic (5)
- # pathom (13)
- # pedestal (6)
- # quil (6)
- # rdf (17)
- # re-frame (32)
- # reagent (34)
- # reitit (30)
- # remote-jobs (1)
- # ring (2)
- # shadow-cljs (149)
- # spacemacs (1)
- # sql (8)
- # tools-deps (90)
- # xtdb (19)
[2.3.0-alpha5]
reader2
and reader3
do different things in ast
(for [reader [pc/reader2
pc/reader3]]
(let [parser (ps/connect-serial-parser
{::ps/connect-reader reader}
[(pc/resolver `b
{::pc/output [:b]}
(fn [env input]
{:b (assoc env :keys (keys env))}))])]
(-> (parser {} [{:>/a [{:b [{:ast [:dispatch-key]}]}]}])
:>/a
:b
:ast)))
=> ({:dispatch-key :b} {:dispatch-key :>/a})
to many joins are always vector
@souenzzo reader3
process is very different from the reader2
, and some things will have to work differently
ahhh i just learned that the env contains the parser 😄 as a relative newcomer to pathom that wasn't obvious.. makes some use cases a lot simpler (or even possible) to implement
This is a bit wordy, but I'm not sure how else to explain it. I have a design where I want to generate some data for a user on the first request for that data, but if they update any of the data I store only the updates (the stored data will be sparse compared to the entire generated data set) A user has a collection of "template" documents. On each request I generate an entity (and it's tree of child properties) in the response for each of the template documents. If the user updates one of the generated entities, then I persist only that entity (with its children). On subsequent requests I will return any existing entities but generate any remaining entities that are in the template list. These are the two main resolvers:
(pc/defresolver user-habit-records-resolver [_ _]
{::pc/output [{:user/habit-records
[{:habit-record/id [:habit-record/id]}]}]})
(pc/defresolver habit-record-resolver [_ _]
{::pc/input #{:habit-record/id}
::pc/output [:server/message :server/error?
:habit-record/id
:habit-record/date
:habit-record/state
{:habit-record/habit-id [:habit/id]}
{:habit-record/task-records [:task-record/id]}]})
user-habit-records-resolver
returns a vector of a mix of just the
habit-record/id and a tree of data that matches the query for habit-record-resolver
for missing entities.
This is currently working, pathom is correctly resolving all the refs in the generated data and for the id case.
My question is: is this supported? Or is this working by "accident" because of the current
implementation of pathom. I don't want to get caught in the future if the implementation should change and break this setup.Working through the Pathom doc examples and I'm stuck on `defmutation`. I define a mutation as in the docs. I see it's a macro that does ~ `(def ~sym ,,, (fn ~sym ~arg ~@body)`, so I expect it to create a function that returns the body I pass to `defmutation`. But when I run the function, it returns `nil` and I can't identify why. <https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/connect/connect-mutations.html#_creating_mutations> ```(pc/defmutation send-message [env {:keys [message/text]}] {::pc/sym 'send-message ::pc/params [:message/text] ::pc/output [:messag/id :message/text]} {:message/id 123 :message/text text}) (def my-app-registry [send-message]) (def parser (p/parallel-parser {::p/env {::p/reader [p/map-reader pc/parallel-reader pc/open-ident-reader p/env-placeholder-reader] ::p/placeholder-prefixes #{">"}} ::p/mutate pc/mutate-async ::p/plugins [(pc/connect-plugin {::pc/register my-app-registry}) p/error-handler-plugin p/request-cache-plugin p/trace-plugin]})) ;; Blows up with "Invalid expression " (<!! (parser {} [(send-message {:message/text "Hello Clojurst!"})])) ;; Returns nil (send-message {:message/text "Hello Clojurst!"})``` Anyone have an idea why? Where am I going astray?
probably just need to quote the symbol:
(<!! (parser {} [(list 'send-message {:message/text "Hello Clojurst!"})]))
That's it. Huh. I swear I tried quoting the entire expression (<!! (parser {} '[(send-message {:message/text "Hello Clojurst!"})]))
and it failed. But it's working now.