Fork me on GitHub
Eric Ihli15:05:12

> > 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?


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

🙏 4

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


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


@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