Fork me on GitHub
#datalog
<
2021-04-15
>
mauricio.szabo19:04:59

A simple-ish question: I'm quite in love with Pathom, but it only supports queries in EQL. Is there an easy-ish way to translate EQL into Datalog (or even into a subset of datalog)?

mauricio.szabo19:04:03

(I think I already asked this question on another channel, right? I my memory didn't fail me 😄)

lilactown19:04:26

are you trying to write to do EQL->datalog so that you can run the query on a database that doesn't support EQL, or are you trying to use datalog with pathom specifically?

mauricio.szabo20:04:06

Datalog with Pathom would be good 🙂

mauricio.szabo20:04:38

To be honest, I saw this post: https://petevilter.me/post/datalog-typechecking/ The idea (on the post) was to expose some functionalities of the IDE as datalog queries

mauricio.szabo20:04:42

I really liked the idea of "I can configure and compose whatever I want just by writing datalog queries and maybe calling some APIs with the results" so I went by and experimented with EQL (because of Pathom) in my plug-ins Chlorine and Clover. So far, it's been a great success

mauricio.szabo20:04:10

But I think that EQL is harder to read, and there's also the issue that it returns data in a specific format only, so you have to re-filter it and mix-and-match with client-side code...

lilactown20:04:26

OK, based on that, it sounds like what you are looking for is a way to use datalog with pathom? not convert EQL to datalog

lilactown20:04:39

you would like to author queries in datalog and use them with pathom

lilactown20:04:49

I don't know of any way of writing datalog queries that leverage pathom. might be a good question for #pathom

Joe Lane20:04:32

Wouldn't you expose pathom resolvers that have datalog underneath them?

Joe Lane20:04:50

Or take queries as args?

lilactown20:04:50

I know that @wilkerlucio has been working on pathom3 which provides the ability to use "smart maps" instead of EQL. it might be interesting to explore datalog as a 3rd alternative interface to pathom

🎸 1
lilactown20:04:31

@lanejo01 I don't think that @mauricio.szabo is trying to figure out how to use a database inside of a pathom resolver; I think he wants to author queries in datalog and execute them against a pathom graph

lilactown20:04:37

unless I am misunderstanding!

mauricio.szabo20:04:52

> to author queries in datalog and execute them against a pathom graph Yes, exactly 🙂

wilkerlucio20:04:20

about Pathom and Datalog, if you get a datalog engine that can work with standard maps (and I believe most of them can), you could give it smart maps and ask for stuff, so pathom would do the data traversing, while datalog does the matching engine

wilkerlucio20:04:50

that said, its also part of the pathom design to keep reshaping data (specially on Pathom 3 that supports nested inputs, so a resolver can do a full query and just reshape it in some other way)

lilactown20:04:10

> reshaping data what do you mean by this?

wilkerlucio20:04:08

for example, if you have a nested structure that you wanna make flat, you could write a pathom resolver like this:

(pco/defresolver nested-to-flat [input]
  {::pco/input  [:thing/id :thing/title
                 {:thing/children '...}]
   ::pco/output [{:flat-items [:thing/id :thing/title]}]}
  {:flat-items
   (tree-seq :thing/children :thing/children input)})

wilkerlucio20:04:09

what I’m thinking is a more generic version of it, you can always compress or expand some data via a resolver, this allows to “pick” parts of a complex nested structure and re-shape into another structure (flat or nested in some other format)

lilactown21:04:08

yeah I think so

wilkerlucio20:04:08

for example, if you have a nested structure that you wanna make flat, you could write a pathom resolver like this:

(pco/defresolver nested-to-flat [input]
  {::pco/input  [:thing/id :thing/title
                 {:thing/children '...}]
   ::pco/output [{:flat-items [:thing/id :thing/title]}]}
  {:flat-items
   (tree-seq :thing/children :thing/children input)})