Fork me on GitHub
#pathom
<
2019-06-10
>
mss18:06:41

are there any working full-stack examples of using a parallel-reader with fulcro?

mss18:06:58

kind of slogging through wiring everything together practically. didn’t realize each resolver in a parallel-reader was going to return a channel, as opposed to the entire parse call returning a single channel to take the query/mutation result from

mss18:06:06

if there’s a way to do that, I’d love to hear it

wilkerlucio18:06:01

@mss in the end you only need to read in the channel that the final parser returns, are you using pathom on the client or in the server?

mss18:06:06

using it on the server. weird, my parser doesn’t seem to be returning a channel. e.g.

(pathom-connect/defresolver test-resolver [env _]
  {::pathom-connect/output [:something/name :something/type]}
  (let [{:keys []} env]
    {:something/name "hey"
     :something/type :something.type/test-type}))

(defn build-parser [config env-entities]
  (pathom/parser
    {::pathom/env (merge {::pathom/reader               [pathom/map-reader
                                                         pathom-connect/parallel-reader
                                                         pathom-connect/open-ident-reader
                                                         pathom/env-placeholder-reader]
                          ::pathom/placeholder-prefixes #{">"}}
                         env-entities)
     ::pathom/mutate pathom-connect/mutate-async
     ::pathom/plugins [(pathom-connect/connect-plugin {::pathom-connect/register [test-resolver]})
                       pathom/error-handler-plugin
                       pathom/request-cache-plugin
                       pathom/trace-plugin]}))

(def my-p (build-parser {} {}))

(clojure.pprint/pprint (my-p {} [:something/name :something/type]))

mss18:06:23

the above returns:

#:something{:name
            #:com.wsscode.pathom.parser{:provides
                                        #{:something/type
                                          :something/name},
                                        :response-stream
                                        #object[clojure.core.async.impl.channels.ManyToManyChannel 0x721582a2 "[email protected]"]},
            :type
            #:com.wsscode.pathom.parser{:provides
                                        #{:something/type
                                          :something/name},
                                        :response-stream
                                        #object[clojure.core.async.impl.channels.ManyToManyChannel 0xca1a4fb "[email protected]"]}}

mss18:06:54

I’m definitely missing or misusing something in my configuration, then. just not clear what. on pathom 2.2.14

wilkerlucio18:06:42

@mss the problem is you are using incompatible things

wilkerlucio18:06:51

you need to use the p/parallel-parser to use the parallel reader

wilkerlucio18:06:57

they have different processing mechanisms

wilkerlucio18:06:23

just replace that, the parser will return a channel, and reading this channel gets you the final response

mss18:06:09

ahhh I understand. wonderful

mss18:06:37

knew I had something configured incorrectly. thanks for putting this library out. it’s really a joy to use

wilkerlucio18:06:01

glad to hear you are enjoying the time with it 🙂