This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-28
Channels
- # announcements (14)
- # autochrome-github (1)
- # babashka (4)
- # beginners (151)
- # biff (1)
- # calva (24)
- # cider (13)
- # clara (13)
- # clj-commons (1)
- # cljs-dev (24)
- # clojure (50)
- # clojure-europe (20)
- # clojure-france (13)
- # clojure-nl (4)
- # clojure-norway (12)
- # clojure-spec (43)
- # clojure-uk (6)
- # clojurescript (30)
- # cursive (2)
- # datahike (9)
- # editors (6)
- # emacs (2)
- # fulcro (29)
- # google-cloud (20)
- # graphql (2)
- # humbleui (2)
- # jobs (2)
- # juxt (4)
- # kaocha (5)
- # lsp (14)
- # malli (5)
- # membrane (10)
- # off-topic (39)
- # pathom (21)
- # polylith (10)
- # rdf (8)
- # reagent (4)
- # remote-jobs (3)
- # reveal (18)
- # shadow-cljs (27)
- # spacemacs (7)
- # tools-deps (30)
Did someone experiment with pantom3 and datahike? I have seen a datomic pantom3 library. What I realized after building my firat datahike app is that there are many situations where that might make sense. An area where I sort of struggle with the datahike api are situations when I add calculated properties to queries. I didn't find a good way to code that. Also I believe pantom3 comes in handy when coding resolvers. And of course it would be huge if we could query graphql apis and datahike from the same queries.
I use pathom2 with datahike and will migrate to pathom3 as soon as I have time for it. The datomic-pathom libraries are a neat experiment, but there are many drawbacks… Mostly around access control. Back to your initial problem: What exactly are your problems with calculated properties? Here is an example of function calls in a datahike query used for searching users by substring:
(defn search-for-user [db search-term]
(d/q '[:find [(pull ?e [::user/id ::user/display-name]) ...]
:in $ ?search-term
:where
[?e ::user/display-name ?dn]
[(clojure.string/lower-case ?dn) ?lc-dn]
[(clojure.string/lower-case ?search-term) ?lc-?search-term]
[(clojure.string/includes? ?lc-dn ?lc-?search-term)]]
db (str search-term)))
; and because you asked for pathom: here the resolver where the function above is used.
(defresolver autocomplete-user [{:keys [db] :as env} _]
{::pc/params [:term :limit]
::pc/output [{:autocomplete/users [::user/id ::user/display-name]}]}
(let [{:keys [term limit] :or {limit 3}} (-> env :ast :params)
limit (min limit 5)]
{:autocomplete/users
(take limit (search-for-user db term))}))
https://github.com/hhucn/decide3/blob/334f691059ffeabaceed2567502a12bfd8fa8b81/src/main/decide/models/user/api.clj#L14Looking at the code right now... I should query the entity ids first, then limit them, then pull the data...
@UCSJVFV35 Another thing about calculated properties… Have you looked at https://docs.datomic.com/cloud/query/query-data-reference.html#rules? They are a great way to have reusable logic in your queries.
I did develop webly, and it can deal with oauth2 tokens, and it has a authentication and authorization layer.
The app I developed I use http://github.com/pink-gorilla/goldly with datahike.