Fork me on GitHub
#pathom
<
2020-05-14
>
Eric Ihli15:05:12

> https://wilkerlucio.github.io/pathom/#_the_environment_plugin > Typically the parsing environment will need to include things you create and inject every time you parse a query (e.g. a database connection) and some parser-related things (e.g. the reader) that might be the same all the time. What is the purpose of having something like the db connection in the environment argument? My connection is defined in another namespace and managed by mount and I've just been requiring it in the namespace where I define my mutations and accessing it directly as required rather than putting it in env and getting it out of there in my mutation. Is there a reason to do it another way?

souenzzo16:05:00

If db is defined on env, you can just assoc your test-db and run your test

🙏 4
kszabo19:05:26

yeah, it’s the classic DI vs. global state question. I would argue that the DI approach is superior albeit it introduces more indirection

kszabo19:05:06

which makes @souenzzo’s case possible without restoring to mount’s own mocking system

fjolne20:05:52

@ericihli there’s also a consistency consideration: env plugin injects the env on every parser call so that you have the same db value in all resolvers in that call

👍 4