Fork me on GitHub
#pathom
<
2021-04-23
>
prnc14:04:01

What is the best way to allow resolvers to access user provided global data? Something like e.g. pbir/constantly-resolver or global-data-resolver (if understand correctly), but user provided. E.g.

(p.eql/process (pci/register [top-level-resolver])
                 {:user-data "Hello"}
                 [{:top-level [:user-data]}]) 
So it’s available to all resolvers regardless of level. Examples I’ve come across are all through modifying the env which I guess I don’t want to do on every request, right? Does that make sense?

wilkerlucio14:04:21

its ok to modify the env on every request, the global things can go there 👍

wilkerlucio14:04:51

env access is more direct, I usually put things like DB connections there for example

wilkerlucio14:04:45

you can also make a resolver, which makes it extensible, but also more expensive and less predictable (compared to env which is always a simple key read)

prnc14:04:52

Nice! That’s one of my use cases, but that can be considered static. The other thing I had in mind was some user identifier that can be used in many places in the graph but may be ofc different for each request and is provided through the initial data. So I guess I will just add that to env instead, thanks!

wilkerlucio08:04:13

yes, user identifier is a common thing that gets filled in the env for each request