pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
dehli 2020-12-11T00:44:48.472100Z

Another question, is it common/encouraged to have system only resolvers? I have some system states that Iโ€™m thinking could be easier to debug/dev if they were represented with resolvers but then iโ€™d need to prevent clients from requesting them directly. One idea iโ€™m running through is having a resolver that returns the database model and then downstream resolvers could take the database model and convert to the application model

souenzzo 2020-12-11T00:54:15.472300Z

I have resolvers that returns db schema, jvm startup data and I'm working//planning resolvers that returns my #pedestal routes and many more (use pathom as a "startup/component" system) For my API, I just filter some keys

dehli 2020-12-11T00:56:16.472500Z

thanks! ya it seems like fully embracing pathom is very powerful

souenzzo 2020-12-11T00:59:54.472700Z

It's hard to code without pathom after use it for a while

1๐Ÿ™‚
wilkerlucio 2020-12-11T06:26:58.473100Z

you can do with a custom ::p/process-error:

1๐Ÿ‘
wilkerlucio 2020-12-11T06:27:00.473300Z

(def mutation-parser
  (p/parser
    {::p/env     {::p/reader               [p/map-reader
                                            pc/reader2
                                            pc/open-ident-reader
                                            p/env-placeholder-reader]
                  ::p/placeholder-prefixes #{">"}
                  ::p/process-error        (fn [env err]
                                             (if (= :call (-> env :ast :type))
                                               (p/add-error (-> env
                                                                (update ::p/path p.misc/vconj (-> env :ast :key))
                                                                (dissoc ::p/process-error)) err))
                                             (p/error-message err))}
     ::p/mutate  pc/mutate
     ::p/plugins [(pc/connect-plugin {::pc/register mutation-error})
                  p/error-handler-plugin
                  p/request-cache-plugin
                  p/trace-plugin]}))

dehli 2020-12-11T12:24:36.473800Z

awesome! thanks so much ๐Ÿ™‚ is it cool for me to create a github issue with the question and then copy you solution there for more visibility?

wilkerlucio 2020-12-11T14:41:34.474100Z

sure, I think this is a good opportunity to try: https://github.com/wilkerlucio/pathom/discussions

1๐Ÿ‘
2020-12-11T15:14:16.474500Z

really really cool! I tried to use the dotfile graphs in one of the namespaces to explore it a bit, but couldn't make much sense out of it. This web-app thing is awesome!

2020-12-11T15:21:31.474700Z

I can imagine that being super useful when you can add durations to the edges for debugging performance.

alidlorenzo 2020-12-11T15:38:04.475600Z

with pathom3, whatโ€™s the correct way to set data (like a db connection) on env context?

alidlorenzo 2020-12-11T15:42:33.475700Z

ah I see that smart maps and eql process both take initial data

alidlorenzo 2020-12-11T15:42:55.475900Z

was trying to use the built-in resolvers at first ๐Ÿ˜…

alidlorenzo 2020-12-11T15:51:10.476100Z

@wilkerlucio seems like initial data is not passed to data map argument that mutations take? For arity two, inspecting env context I do see the initial data, but not sure which way Iโ€™m supposed to be accessing it.

wilkerlucio 2020-12-11T15:52:11.476300Z

when create Smart Maps or EQL trigger, the first argument is the env, you should set the db connection there, same for mutations

wilkerlucio 2020-12-11T15:52:33.476500Z

like: (psm/smart-map (assoc env ::my-db ...) {:my.customer/id "123"})

wilkerlucio 2020-12-11T15:56:00.476800Z

makes sense?

alidlorenzo 2020-12-11T15:56:40.477Z

so pathom-indexes/register creates an env (not just indexes), and we can assoc additional env values into it before calling smart-map or eql process

alidlorenzo 2020-12-11T15:57:42.477200Z

iโ€™m trying this

(pathom-eql/process
   (assoc indexes
          ::ctx/conn (dc/conn))
   eql))
but assocโ€™ed data does not seem to be included in map passed to mutations

wilkerlucio 2020-12-11T15:59:31.477400Z

there are two maps, the env and params

alidlorenzo 2020-12-11T15:59:38.477600Z

hm i guess i have to use arity two to access it

wilkerlucio 2020-12-11T15:59:40.477800Z

to use env you need to declare the mutation with both

alidlorenzo 2020-12-11T15:59:54.478Z

^ yeah, i thought since everything was namespaced itโ€™d be in one map

wilkerlucio 2020-12-11T16:00:02.478200Z

(pco/defmutation mmmm [env params])

wilkerlucio 2020-12-11T16:00:12.478400Z

nope, two different contexts of information

1๐Ÿ‘
wilkerlucio 2020-12-11T20:03:50.478800Z

wilkerlucio 2020-12-11T20:04:08.478900Z

parts of Pathom Viz integrated in Reveal

2020-12-11T20:57:43.479100Z

This is awesome!! :star-struck::star-struck::star-struck: