Fork me on GitHub
#pathom
<
2019-12-18
>
colinkahn16:12:43

Is it advisable to call my parser within a mutation, for example if I want to call other mutations I've registered?

wilkerlucio20:12:53

I suggest instead you make the mutations more atomic like. they are a final entry point, its better if you abstract the internals so you can share that between mutations, makes sense?

colinkahn22:12:19

@U066U8JQJ yep, definitely. Is it common to do other parser queries within mutations? Like lets say I need to know the current state of something. Or should the parser be considered more of an interface for the outside world and internally use whatever storage i’m building against to query for things?

wilkerlucio22:12:00

@U0CLLU3QT you usually don't need it, the response of a mutation usually has some data about what was transacted, if the user do a mutation join (running a query against the result), them pathom will already trigger the resolver engine to consolidate the gap between the mutation output and the user data, this is what I see happening most of the time

colinkahn22:12:07

@U066U8JQJ thanks for the insight, really liking pathom so far!

🙏 4
kszabo17:12:35

yes, that’s idiomatic

souenzzo20:12:27

(let [register [(pc/resolver `foo
                             {::pc/output [::foo]}
                             (fn [{::keys [foo]} _]
                               {::foo foo}))
                (pc/resolver `parser
                             {::pc/output [::parser]}
                             (fn [{:keys [parser] :as env} _]
                               {::parser [(parser (assoc env ::foo 1)
                                                  [::foo])
                                          ;; how do I "cleanup" env cache here?
                                          (parser (assoc env ::foo 2)
                                                  [::foo])]}))]
      p (p/parser
          {::p/env     {::p/reader               [p/map-reader
                                                  pc/reader2
                                                  pc/open-ident-reader
                                                  p/env-placeholder-reader]
                        ::p/placeholder-prefixes #{">"}}
           ::p/plugins [(pc/connect-plugin {::pc/register register})]})]
  (p {} [::parser]))
How do I control/cleanup env cache?

souenzzo21:12:05

using

(assoc env
  ::p/request-cache (atom {})
  ::p/entity (atom {}))