pathom

:pathom: https://github.com/wilkerlucio/pathom/ & https://pathom3.wsscode.com & https://roamresearch.com/#/app/wsscode
2020-10-21T01:18:06.146Z

I got it working! Thanks for the help y’all

wilkerlucio 2020-10-21T12:51:32.146200Z

hello, for your case @tekacs, you can go around this limitation by writing a mutation that sends multiple messages at once

wilkerlucio 2020-10-21T12:51:47.146400Z

or, some sort of mutation that composes other mutaitons

exit2 2020-10-21T13:55:09.146700Z

I ended up co-located the clj/cljs mutation files so they have the same namespace in the mean time

yenda 2020-10-21T14:54:32.146900Z

@wilkerlucio I merge queries into one until it can be sent, on retry it does one single query with all the pending ones

1πŸ‘
2020-10-21T17:21:59.147200Z

right, what yenda said @wilkerlucio

2020-10-21T17:22:13.147400Z

merging them into one doesn't really help, because it'd break ordering for one thing

2020-10-21T17:22:22.147600Z

[(mutation-1)
 (mutation-2)
 (mutation-1)]

2020-10-21T17:22:51.148Z

the only real option as far as I can tell is to manually split the mutations externally to Pathom and then to send them into the engine one at a time 😞

2020-10-21T17:28:32.148700Z

I guess I could write a mutation that composes other mutations...

2020-10-21T17:29:09.148900Z

but would be wonderful if there were an ad-hoc way of simply giving each mutation its output name

yenda 2020-10-21T17:44:01.149100Z

which is why I was wondering if it could return a collection of results when the mutation was called more than once

yenda 2020-10-21T17:45:52.149300Z

if I'm not mistaken that would not even break existing queries, since for instance

(defn block-user
  [user-id blocked?]
  {(list 'block-user {:user/id user-id
                      :user/blocked? blocked?})
   [:user/id
    :user/blocked?]})
could anyway receive either one map or a coll of map

2020-10-21T18:01:05.149500Z

if we could rename outputs, then we could get the same effect as a collection by transforming queries to/from a form with renames

2020-10-21T18:01:10.149700Z

that's why that'd be my aim

2020-10-21T18:01:21.149900Z

I might see if I can do that in a plugin

yenda 2020-10-21T18:04:43.150100Z

If I'm not mistaken the overwrite occurs in mutate and mutate-async when the result is merged in the env

yenda 2020-10-21T18:16:48.150300Z

mhm actually looks like it's in the parser

yenda 2020-10-21T18:17:09.150500Z

(recur (assoc res (ast->out-key ast) value) tail)

yenda 2020-10-21T18:21:50.150700Z

would it be acceptable to do

(let [out-key (ast->out-key ast)
      previous-res? (get res out-key)]
  (recur (if previous-res?
           (update res out-key (fn [previous-res]
                                 (if (vector? previous-res)
                                   (conj previous-res res)
                                   [previous-res value])))
           (assoc res out-key value)) tail))

wilkerlucio 2020-10-21T18:44:00.150900Z

@yenda the vector thing is a problem, because it breaks the assumption that mutations always return a map, I think a behavior like that could be confusing. there is a plugin entry point that I've been considering for a while, and I think it could solve this problem, is a ::p/wrap-output, something to run exactly when pathom is building the output, with this hook you could either write a plugin to use some param and have some different output name (like alias works for reads today) or even make what you are suggesting. this was planned for Pathom 3, but I can make in Pathom 2, this can also give some room to experiment with this entry point

yenda 2020-10-21T18:53:59.151100Z

yeah the plugin way would be satisfying enough, I had the assumption mutations would return a vector when ran more than once like resolvers when they return more than one result πŸ˜„

2020-10-21T19:11:22.151800Z

I would curious to hear if there any plans to add Pathom 3 defresolver-style sugaring (inference of params, output, removing env/params) to the defmutation syntax, at all?

wilkerlucio 2020-10-21T19:35:31.152200Z

maybe, I didn't started mutations in Pathom 3 yet

wilkerlucio 2020-10-21T19:48:05.152400Z

but I think it should, just instead of inferring inputs, it will infer params

1❀️