Fork me on GitHub
#pathom
<
2020-04-09
>
timeyyy08:04:08

Hey all. Is there a way to enable hot code reloading of pathom resolvers and mutations? I have to keep restarting my repl to get changes to my resolvers to pick up :thinking_face:

fjolne12:04:31

@U7V6UECH1 you’d probably want to use some state management lib (like https://github.com/tolitius/mount) and reloaded workflow (via https://github.com/clojure/tools.namespace) then you can reload the code and reinstantiate pathom instance with one function you can look at how it’s implemented here https://github.com/fulcrologic/fulcro-template (no need to use fulcro itself)

stevej13:04:05

eval the resolver and the parser again will get changes to show up. I am just experimenting with pathom in a single file to learn it and that is working for me

fjolne13:04:32

that’s a good approach for a simple setup as pathom per se doesn’t have a lifecycle semantics, but in general case there’s a http server and other stuff which depends on pathom and which needs to be properly reloaded when resolvers change

👍 4
kszabo18:04:31

I would recommend integrant: https://github.com/weavejester/integrant after using 4 years of mount

kszabo18:04:39

DI > globals

kszabo18:04:42

which mount promotes

fjolne19:04:26

@U08E8UGF7 i also used integrant on a few commercial projects, but one state map + multi-methods all over the place turned out to be somehow less manageable i’d really appreciate if you explained a bit more why you prefer integrant i might guess that’s in line with reasoning why people prefer data-driven vs macros like in the the shift from compojure to reitit i also see how integrant is more manageable in terms of testing, but still multi-methods

kszabo20:04:39

it’s exactly your points. Multi-methods is a necessary evil that I’m willing to take on. (I would prefer the data-driven pathom resolver approach if I would design it today). One benefit though with the ns-load side-effects that you can use the built-in load-namespaces function and name your components with keywords that have backing namespaces, then you can start your system map in your cli namespace without any knowledge where those multimethods reside. Essentially the system map can always initialize itself by deriving the implementation from it

👍 4
fjolne20:04:13

huh, seems like i’ve been doing a similar thing, but in a more hacky way and felt guilty for it, thanks! might be worth giving integrant another spin