Fork me on GitHub
#om
<
2017-10-24
>
wilkerlucio11:10:55

Hello people, today I like to share a video with you, this video shows a way that you can get auto-complete exploratory features for your Om.next graphs. This is a combinations of technologies, being Pathom a backend library that helps you write your parsers, and OgE, that's a web interface to explore your graph. I made a video to demonstrate how you can combine those and have a good exploratory solution for your graphs, I hope you enjoy it: https://www.youtube.com/watch?v=60i9uStI9As

gardnervickers15:10:30

@wilkerlucio Very cool, have you thought about generating the parser index from clojure.spec fspec’s?

wilkerlucio15:10:35

@gardnervickers thanks 🙂, yes, actually, if there is a spec it will try to infer automatically from that, the major problem here is that spec keys doesn't support describing nested structures, which is important for many resolvers

wilkerlucio15:10:06

but if your resolver has a flat output, and you have a spec for it, pathom will infer automatically, you just need to send the symbol

vinnyataide17:10:50

Hello guys! I have the current atom as database (atom {:navbar {:active "index" :current-user "user"}}) Is there a reason why the query

(parser {:state state} [{:navbar [:active]}])
returns the whole atom? aka:
{:navbar {:active "index", :current-user "user"}}

vinnyataide17:10:42

Here's my read fn

(defn read
  [{:keys [state] :as env} key params]
  (let [st @state]
    (if-let [[_ v] (find st key)]
      {:value v}
      {:value :not-found})))

wilkerlucio19:10:40

@vinnyataide the parser only runs for the top-level attributes, it's your job to call it recursively if you wanna have sub-queries working

wilkerlucio19:10:59

see that at {:value v} you are returning the full :navbar, so that's what you see in your response

wilkerlucio19:10:43

if you don't care much about a custom local parser, I recommend you to try fulcro, with that you can eliminate the need for a local parser

wilkerlucio19:10:09

or, if you wanna know more about writing parsers, you can read my article about that 🙂 https://medium.com/@wilkerlucio/implementing-custom-om-next-parsers-f20ca6db1664

wilkerlucio19:10:47

but just as a heads up, I think with this code your parser would work (for this case you mentioned at least):

vinnyataide19:10:49

@wilkerlucio I'll definitely look at your parser article. Never thought that the value would not match the full map

wilkerlucio19:10:49

(defn read
  [{:keys [state parser query] :as env} key params]
  (let [st @state]
    (if-let [[_ v] (find st key)]
      (if (and query (map? v))
        {:value (parser env query)}
        {:value v})
      {:value v}
      {:value :not-found})))

wilkerlucio19:10:10

but this is an incomplete implementation, you still have to deal with sequences

vinnyataide19:10:37

Hm so I had to implement all the parser and all it's funcs... That's low level. Why is om not responsible for that?

wilkerlucio19:10:48

humm, sorry, maybe this doesn't work at all (the example)

wilkerlucio19:10:06

but about your question, the Om design is to be open to any kind of database, not just clojure maps, one example is datascript

wilkerlucio19:10:32

that's why I recommend fulcro, fulcro embraces the database as map, and implement a lot of plumbing that you would have to write yourself (and it's not trivial)

vinnyataide19:10:50

Oh okay... I thought the queries were passed as is.

vinnyataide19:10:27

Since I'm using full clojure datomic that's easy to choose

wilkerlucio19:10:07

no problem 😉

vinnyataide20:10:13

mind blown... holy cow great blog post!

vinnyataide20:10:22

the code style is beautiful

ag21:10:48

hey guys, I'd like to send a remote query, that serves a file. e.g. csv. How can I do it without using a specialized remote? Meaning how can I use existing scaffolding that works for "tabular" data, but this time instead of returning {:value data ,, etc. I'd love to serve .csv file