Fork me on GitHub

Are there any drawbacks of making the resolvers look into their context for any component they need (e.g. a database) instead of (as the tutorial suggests) getting passed that dependency via a closure?


It's situational and/or personal choice. The FieldResolver protocol was a later addition. Generally, if a field resolver is stand-alone (no dependencies, just a pure function), I prefer it to be a simple function; if it has component dependencies, I prefer it to be a component implementing FieldResolver. But at the same time, the application context exists specifically so that the outer application (typically, your Pedestal interceptor chain) can provide values that will be needed by field resolvers (or to allow outer field resolvers to provide data to inner field resolvers).


Oh cool, I missed the field resolver protocol.


I’d like (during development) to be able to re-eval a single resolver and have it have immediate effect, without actually having to re-eval some other things as well (e.g. my system).


I do that by changing the resolver reference to #'my-resolver before starting my system. Then I can re-evaluate it.


That works when the resolver is just a function, but not when it is constructed by closing over some stateful component, right?


oh, sorry. i missed that context.


Np :) that var trick is quite cool - and unless I misunderstand it, it’s a Clojure thing.


I tend to use a workflow that will recompile the schema on each request. That's too slow for production and under load, but perfectly OK for interactive development and testing.


Yes, we do the same! Now if only Graphiql would reload the schema :)