pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
nivekuil 2020-08-18T07:17:43.054900Z

this is probably a micro optimization but all my batch resolvers end like this:

(if (> (count input) 1)       (pc/batch-restore-sort {::pc/inputs ids ::pc/key :view/id} result)       result)
is there a better way of doing this pattern?

ak-coram 2020-08-18T07:52:10.055100Z

I have a macro that takes a sort key and generates this (and is also doing some async error handling stuff)

mischov 2020-08-18T14:58:28.057Z

Has anybody used any kind of permissions based access control with pathom? If so, was it based on a library or framework, or did you roll your own? Anybody have any examples?

lgessler 2020-08-18T17:41:43.057100Z

there's no library for this afaik, some discussion of this here: https://github.com/souenzzo/eql-style-guide/issues/4

👍 1
lilactown 2020-08-18T18:23:35.057800Z

where’s the best place to look for implementing unions?

lilactown 2020-08-18T18:35:38.058500Z

also, what’s the best way to manually return a “not found” value? return ::p/not-found? or is there a function I should call?

souenzzo 2020-08-18T20:07:45.059400Z

@lilactown for not-found: do not return the key. Resolvers "maybe" return the keys in output. If none, it will be marked as not-found

wilkerlucio 2020-08-18T20:51:05.060700Z

@lilactown you can return ::p/not-found directly as a way to short-circuit the thing, the difference will have in cases where there are multiple paths for that, that said, the preferred way is like @souenzzo said, dont return the key

lilactown 2020-08-18T20:56:04.062Z

I’m not sure how to use the terminology correctly yet, so apologies if this is verbose. I have a resolver that I want to return a not-found value from

lilactown 2020-08-18T21:00:59.066400Z

to reuse my folders example (because it is the same thing I’m working on 😄 ) :

(pc/defresolver folder-tree-resolver
  [{:keys [db]} {:keys [::folder/id]}]
  {::pc/input #{::id}
   ::pc/output [{::tree (vec (concat file-keys folder-keys))}]}
  (let [files (list-files db)
        folders (list-folders db)
        children (filter (comp #(= % id) ::folder/parent) (concat files folders))]
    {::tree (if (empty? children)
              ::p/not-found ;; no children for this particular node
              (vec children))}))

lilactown 2020-08-18T21:02:09.067200Z

so in this case, when a ::folder/id key exists in the context it will look up to see if any files or folders declare it a parent

lilactown 2020-08-18T21:02:45.068200Z

in the case where it found no files or folders, I think it’s better to return ::p/not-found (and have it elided by the plugin) then an empty vec

wilkerlucio 2020-08-18T21:02:47.068300Z

maybe something like this if I got right:

(pc/defresolver folder-tree-resolver
  [{:keys [db]} {:keys [::folder/id]}]
  {::pc/input #{::id}
   ::pc/output [{::tree (vec (concat file-keys folder-keys))}]}
  (let [files (list-files db)
        folders (list-folders db)
        children (filter (comp #(= % id) ::folder/parent) (concat files folders))]
    (if (seq children)
      {::tree (vec children)})))

wilkerlucio 2020-08-18T21:03:05.068600Z

sorry

wilkerlucio 2020-08-18T21:03:06.068800Z

fixing itt

wilkerlucio 2020-08-18T21:03:19.069100Z

ok, should be right now

lilactown 2020-08-18T21:03:37.069300Z

ahh so returning no map would be akin

wilkerlucio 2020-08-18T21:03:43.069500Z

yeah, or empty map

lilactown 2020-08-18T21:04:21.069900Z

cool! I figured it was strange to return the keyword. that helps, thanks!

lilactown 2020-08-18T21:04:43.070Z

ty!

wilkerlucio 2020-08-18T21:05:04.070500Z

smaller tip, you can use filterv on the children

2
lilactown 2020-08-18T21:05:57.070600Z

it doesn’t look the the source code in the docs for that demo, matches the demo query

wilkerlucio 2020-08-18T21:10:07.070900Z

ups

wilkerlucio 2020-08-18T21:10:31.071100Z

fixing it now

lilactown 2020-08-18T21:10:42.071300Z

🙏:skin-tone-2: thanks!

wilkerlucio 2020-08-18T21:13:22.071500Z

fixed 👍

1