pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
nivekuil 2021-02-16T03:14:23.264Z

trying to implement the above, but not sure what's wrong

(defresolver response [{:keys [uri]}]   {::pco/output [::response]}   (p/let [response (http/get uri)]     {::response response}))  (def smart-map (psm/smart-map (pci/register response) {:uri "<https://pathom3.wsscode.com>"}))  (::response smart-map) =&gt; nil
with the log line: WARN :com.wsscode.pathom3.connect.runner/invalid-resolver-response - {:com.wsscode.pathom3.connect.operation/op-name app.resolver.uri/response, :response #object[java.util.concurrent.CompletableFuture 0x22b2c2f4 "pending"]} the response does appear to be correctly fetched within the resolver if I log/spy it

souenzzo 2021-02-16T12:05:34.265300Z

@kevin842 you are using an async (returns a CompletableFuture) resolver with a sync runner (smart-maps) For now, as far i know, to async you need to use the "process" with env+query

wilkerlucio 2021-02-16T13:59:36.265800Z

@kevin842 you can't use async with smart maps, you need to use the async EQL process for this

nivekuil 2021-02-16T15:07:06.266200Z

ah thanks. don't see it mentioned in docs, will it be added someday?

nivekuil 2021-02-16T15:08:08.266300Z

nvm it is mentioned, but not too explicitly: To async, there is only the EQL interface

Chicão 2021-02-16T15:20:04.268600Z

Hi, when I invoke my logout mutation and pass the values to it, inside it I see the namespace/request instead of the value, does anyone know why this happened?

(p.eql/process env
               [`(logout {::request request
                             ::url url
                             ::cookie-store new-c})])

wilkerlucio 2021-02-16T15:24:37.268700Z

its because you are using the backtick to expand, you have to use ~ before the values to get them there

wilkerlucio 2021-02-16T15:24:47.268900Z

(p.eql/process env
               [`(logout {::request ~request
                             ::url ~url
                             ::cookie-store ~new-c})])

👍 1
Chicão 2021-02-16T15:33:24.269100Z

thks

nivekuil 2021-02-16T16:13:39.269400Z

will pathom ever walk the same node twice? e.g. A-&gt;(B | C) C-&gt;target B-&gt;A' will pathom ever cycle back to A from A'? I have an alias resolver from A'-&gt;A but it seems it never walks back to A, to retry the A-&gt;C-&gt;target path again starting from A'

dehli 2021-02-16T16:28:43.270Z

I believe the default behavior is that it won’t b/c the resolver’s response is cached for a specific input

nivekuil 2021-02-16T16:35:42.271100Z

that's a good point, but A' would have a different value than A (and I wouldn't want it to loop if they were equal), and I think the cache is keyed based on the resolver params?

nivekuil 2021-02-16T16:38:36.271300Z

tried setting ::pco/cache? false on everything, no diff

Chicão 2021-02-16T16:43:55.272700Z

I had this mutation and when I invoke it, got this error Can't find a path for :async

(pco/defmutation logout [{::keys [request url cookie-store] :as logout-input}]
  (http/post url (assoc request :cookie-store cookie-store))
  logout-input)
how I called the mutation
(p.eql/process env
               [(logout {::request request
                             ::url url
                             ::cookie-store new-c})])
I need to use something like async runner to mutation with http calls?

dehli 2021-02-16T16:44:13.272900Z

Ahhh, so in your example A' would go through the resolver A but it’s a different “id” from what the initial A resolver was called with

nivekuil 2021-02-16T16:46:27.273500Z

yeah, an alias-resolver creates that path from A' to A, i.e. A with the value of A'

dehli 2021-02-16T16:47:04.273700Z

pathom3 uses https://cljdoc.org/d/funcool/promesa/6.0.0/doc/user-guide. I’m not sure which http library you’re using but if it returns a promise you can do something like:

(:require [promesa.core :as p])

(pco/defmutation logout ...
  (p/let [response (http/post url)]
    ;; Use response as you'd like

👍 1
Chicão 2021-02-16T16:47:32.274100Z

nice, thanks for help me

👍 1
dehli 2021-02-16T16:47:51.274300Z

if the lib uses core.async, then you can look into https://github.com/wilkerlucio/promesa-bridges

👍 1
wilkerlucio 2021-02-16T17:19:47.274800Z

yes, Pathom may duplicate the same node in different points of execution, this may happen with OR cases

wilkerlucio 2021-02-16T17:19:58.275Z

but no cycles

wilkerlucio 2021-02-16T17:20:03.275200Z

the planner never has cycles

nivekuil 2021-02-16T17:21:01.275400Z

got it. I just ended up explicitly specifying the connection. this is super cool.. I think I am actually going to try to replace my entire backend with pathom :p

nivekuil 2021-02-16T17:21:14.275600Z

the i/o parts at least

wilkerlucio 2021-02-16T17:34:13.275800Z

@matheusfrancisco001 I just noticed the way you are calling the mutation is wrong

wilkerlucio 2021-02-16T17:34:27.276Z

you removed teh backtick thing

wilkerlucio 2021-02-16T17:34:33.276200Z

and the mutation needs to be as data

wilkerlucio 2021-02-16T17:34:43.276400Z

in the way you doing, you are invoking the mutation and returning is result as a query

wilkerlucio 2021-02-16T17:35:17.276600Z

the code we talked before was right, as:

(p.eql/process env
               [`(logout {::request ~request
                             ::url ~url
                             ::cookie-store ~new-c})])

wilkerlucio 2021-02-16T17:35:28.276800Z

☝️ this and what you are doing are not equivalent

Chicão 2021-02-16T17:36:18.277Z

Wow, thanks a lot!

Chicão 2021-02-16T17:41:33.277200Z

it's worked.

🎉 1
nivekuil 2021-02-16T18:49:03.277500Z

debugging with pathom viz, I see that a node I expect to succeed has this attached to it:

:com.wsscode.pathom3.connect.runner/node-error  #object[Object [TaggedValue: unknown, #error {  :cause "Insufficient data"  :data {:required {:app.pathom.uri/response {}, :app.pathom.uri/response-url {}}, :available {}}
but scrolling down, I do see valid data in node-resolver-input:
:com.wsscode.pathom3.connect.runner/node-resolver-input  {:app.pathom.uri/response ...   :app.pathom.uri/response-url ...}

nivekuil 2021-02-16T18:52:02.277600Z

not sure what the cause is.. the nodes go like response -&gt; response-url -&gt; OR -&gt; (node with error | OR | another node)

nivekuil 2021-02-16T18:58:36.277700Z

the node with error is reachable through some queries but not others, even though they should follow the same initial path.. hm. seems I have to explicitly specify another attribute in the query, but I would expect pathom to be able to get to it regardless? should it be necessary to "hint" the planner like this?

nivekuil 2021-02-17T15:25:24.278300Z

let me demonstrate a different, maybe related planner behavior, with viz nodes:

nivekuil 2021-02-17T15:26:03.278500Z

nivekuil 2021-02-17T15:26:16.278900Z

nivekuil 2021-02-17T15:27:00.279300Z

the top picture is with the bottom-left -&gt;view resolver with a higher priority. it takes that path, realizes it doesn't have enough info, and just dies, neglecting the middle response-&gt;response-url path

nivekuil 2021-02-17T15:27:29.279500Z

bottom picture doesn't set a priority on the bottom-left -&gt;view, it takes the proper path and succeeds

nivekuil 2021-02-17T15:27:43.279700Z

it seems like the planner is not capable of backtracking in general?

nivekuil 2021-02-17T18:28:07.290200Z

tested the latest commit and it seems both cases I ran into here now work as expected. thanks @wilkerlucio ! :D

wilkerlucio 2021-02-17T18:29:06.290400Z

there was some planning fixes that landed yesterday, I guess they fixed your case too 🙂

wilkerlucio 2021-02-17T18:29:29.290700Z

the error handler does backtracking

wilkerlucio 2021-02-17T18:29:37.290900Z

if you find any other weird cases, please let me know

👍 1
wilkerlucio 2021-02-17T18:38:15.291200Z

@kevin842 another thing that may be interesting to you, if you look in the meta, in the node-stats key, if there is any error, it will have a key called "nodes-with-errors", this is a more "global" way to find any errors, you can use this a way to ask the question: did any error happen?

wilkerlucio 2021-02-16T20:58:00.277900Z

yup, I keep doing that, a lot of Pathom Viz UI work is also supported by pathom inside 🙂

dehli 2021-02-16T21:55:02.278100Z

can you post what the failing query looks like and the relevant resolvers (pseudocode is fine)