Fork me on GitHub
#pathom
<
2020-05-25
>
markaddleman19:05:50

I have a pathom client that speaks json and I'd rather not have to get it to speak edn. Does anyone know of a json form of eql that has a straightforward translation to eql?

markaddleman19:05:07

I'm particularly concerned about representing idents and eql parameters.

myguidingstar19:05:59

what do you mean by "pathom client that speaks json"?

souenzzo19:05:06

I have a lib called eql-as that I use for it. Checkout "RealWorld" example In the product that I work on, we use to map a REST API, with unqualified keys, both GET and POST's to EQL queries then dispatch it for a parser that only knows about qualified keys https://github.com/souenzzo/eql-as

markaddleman19:05:01

I mean, my client is a typical browser-based javascript application. I want it to make queries that would be resolved by my pathom server-side application

markaddleman19:05:59

@U2J4FRT2T Thanks! The library looks like it will be helpful after I come up with a json syntax for eql. My challenge right now is to come up with that syntax! 🙂

souenzzo19:05:33

This lib still incomplete. any kind of feedback is welcome 🙂

👍 4
myguidingstar19:05:05

it uses planner, btw

myguidingstar19:05:32

what do i have to change beside the dynamic resolver function?

myguidingstar19:05:01

eg: change p/parser to p/parallel-parser, pc/reader3 to something...

markaddleman21:05:39

It looks like pathom does an outer join when the results of two resolvers are joined together. Is there a way to get it to do an inner join instead?

wilkerlucio01:05:56

not sure what you mean, can you give an example?

markaddleman03:05:58

(ns com.wsscode.pathom.book.connect.getting-started2
  (:require [com.wsscode.pathom.core :as p]
            [com.wsscode.pathom.connect :as pc]))


(pc/defresolver people-resolver [_ _]
  {::pc/input  #{}
   ::pc/output [{:people [:name]}]}
  {:people [{:name "Mark"}
            {:name "Joe"}]})

(pc/defresolver address-resolver [_ {:keys [name]}]
  {::pc/input  #{:name}
   ::pc/output [:address]}
  (if (= name "Mark")
    {:address "111 Main St"}))

(def app-registry [people-resolver
                   address-resolver
                   pc/index-explorer-resolver])

(def parser
  (p/parser
    {::p/env     {::p/reader [p/map-reader
                              pc/reader2
                              pc/open-ident-reader]}
     ::p/mutate  pc/mutate
     ::p/plugins [(pc/connect-plugin {::pc/register app-registry})
                  p/error-handler-plugin
                  p/trace-plugin]}))

(parser {} [{:people [:name :address]}])

markaddleman03:05:36

The result is

{:people [{:name "Mark", :address "111 Main St"} {:name "Joe", :address :com.wsscode.pathom.core/not-found}]}
I'd like to filter out Joe

markaddleman03:05:51

I suspect that I have to write a plugin to do this. Am I on the right track?

markaddleman03:05:40

After looking at the plugin architecture, I think that's the wrong approach. Perhaps post-processing the results is the right way