Fork me on GitHub
#pathom
<
2021-11-01
>
Jakub Holý (HolyJak)12:11:09

Hi @wilkerlucio, I really enjoyed your data navigation with P3 talk, thanks a lot! It is both a great explanation of the problems with REST (and GraphQL) and a wow-ing demonstration of the powers of Pathom. Certainly going to recommend it further!

❤️ 6
mynomoto13:11:10

Is it possible to update the env from a mutation?

mynomoto13:11:13

Usecase: I write on datomic and want to add the db-after to the env.

pithyless13:11:23

I have the same use-case and pass {:db (atom (datomic/db datomic-conn)), :datomic-conn datomic-conn} as env. That way I can update :db with :db-after during the mutation and use @db in the resolver.

mynomoto13:11:12

Does the return of the mutation updates the env? I'm not following how what you are suggesting works.

robert-stuttaford14:11:01

@U05476190 do you use PathomViz? if you do, how do you remove the datomic data from your env before sending it to Viz?

pithyless14:11:07

No, at the moment I'm using P2 and Fulcro inspector (which shows EQL and some perf stats), but not the newest PathomViz which shows env, etc. But I've been following your thread about cleaning up the env data @U0509NKGK and I'm looking forward to a clean approach (and finally getting PathomViz setup and migrating to P3).

pithyless14:11:47

I will say the problem seems similar to issues in P2 with it returning indexes that were not serializable, where we just made a custom resolver middleware that dissoc the pathom-indexes, etc.

pithyless14:11:44

@U05094X3J - in the mutation, you want to (reset! (:datomic-db env) db-after) as a side-effect, and then return whatever you normally return from the mutation; and in the resolver you want to use (deref (:datomic-db env)) as the DB you pass into queries. Since you are storing it as (atom (datomic/db datomic-conn)) the atom takes care of the coordination; and Pathom guarantees read-after-write semantics for "first run mutations, then run resolvers"

pithyless14:11:10

(Going afk now, but hope that makes sense)

mynomoto14:11:40

Oh, I missed the atom part. This helps a lot, thanks!

Björn Ebbinghaus10:11:04

In Pathom 2 you can return a new env in your mutations: {:com.wsscode.pathom.core/env (assoc env :db db-after)}

pithyless10:11:31

Interesting… #TIL

mynomoto12:11:03

Is there something like this env update on pathom3 @wilkerlucio ?

wilkerlucio18:11:53

I'm a bit reluctant to add this back, the reason is that I've seen a couple of cases where you end up leaking your env out by accident, and that is really bad, so I hater find another way to handle those cases, the atom is a valid one that's less risky

👍 1
mynomoto18:11:17

Ok, thank you!

souenzzo11:11:24

I recoomend use ::my-app/db as a "input", not as a env