Fork me on GitHub
#pathom
<
2022-12-06
>
Tommy23:12:19

is there a way to update the resolver env in between running a mutation, and resolving the queries it is joined on? my use case is that I put an immutable DB view at the start of each pathom request, but after a mutation, i need to update that view to a newer one

Tommy00:12:44

I am going to use ::pcr/wrap-mutate plugin, will update if it works

Tommy02:12:22

that did not work, I don't see a way to modify the env for the mutation's query from the wrap-mutate function

pithyless02:12:39

I’ve solved this problem in pathom2 and pathom3 by passing in the DB as an immutable value wrapped in an atom (and possibly a separate DB conn if necessary for mutations) in the env. The queries should deref the db-value atom and the mutations should swap! the db-value atom after successful write with the updated DB.

👌 2
pithyless02:12:28

I understand there was some separate mechanism for updating env in p2 by returning a special key, but IIRC this was removed in p3. Not sure if there is a more idiomatic way to do this in p3 now, but this approach has worked for me :)

👍 1
Tommy02:12:05

ah that is clever, thank you