This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-18
Channels
- # atom-editor (5)
- # babashka (15)
- # beginners (80)
- # calva (11)
- # cestmeetup (6)
- # chlorine-clover (15)
- # cider (22)
- # circleci (3)
- # clojure (57)
- # clojure-europe (19)
- # clojure-italy (1)
- # clojure-nl (4)
- # clojure-spec (1)
- # clojure-switzerland (1)
- # clojure-uk (88)
- # clojurescript (92)
- # code-reviews (1)
- # cursive (6)
- # data-science (5)
- # datascript (6)
- # datomic (12)
- # events (7)
- # figwheel-main (2)
- # fulcro (55)
- # graalvm (2)
- # helix (6)
- # juxt (6)
- # kaocha (11)
- # luminus (2)
- # off-topic (82)
- # pathom (27)
- # portal (1)
- # re-frame (3)
- # reitit (25)
- # remote-jobs (8)
- # sci (11)
- # shadow-cljs (29)
- # slack-help (2)
- # spacemacs (9)
- # specter (4)
- # sql (9)
- # tree-sitter (1)
- # uncomplicate (1)
- # xtdb (26)
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?I have a macro that takes a sort key and generates this (and is also doing some async error handling stuff)
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?
there's no library for this afaik, some discussion of this here: https://github.com/souenzzo/eql-style-guide/issues/4
https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/connect/resolvers.html#_union_queries
it doesnāt look the the source code in the docs for that demo, matches the demo query
fixing it now
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?
@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
@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
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
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))}))
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
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
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)})))
sorry
fixing itt
ok, should be right now
yeah, or empty map