Fork me on GitHub

[2.3.0-alpha5] reader2 and reader3 do different things in ast

(for [reader [pc/reader2
  (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]}]}]}])

=> ({:dispatch-key :b} {:dispatch-key :>/a})


does pathom not let you return a set for a to-many join?


i'm seeing a join work when returning a vector, but not for a set


to many joins are always vector


@souenzzo reader3 process is very different from the reader2, and some things will have to work differently

👍 8

cool, thanks


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/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.

Eric Ihli19:05:00

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 [email protected])`, 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. <> ```(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 #{"&gt;"}} ::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 " (&lt;!! (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!"})]))

Eric Ihli20:05:29

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.

Eric Ihli20:05:14

Hm. Well heck. Wish I could go back in time and figure out what was really going on earlier when the quote wasn't working. Oh well. Thanks!


np, it happens!