claro.middleware.intercept

A middleware to allow partial resolution of batches using a custom resolver.

wrap-intercept

added in 0.2.20

(wrap-intercept engine intercept-fn)

Wrap the given engine to allow resolution of partial batches using different means (e.g. a cache lookup).

(defonce engine
  (-> (engine/engine)
      (wrap-intercept
        (fn [env batch]
          (lookup-in-cache! env batch)))))

intercept-fn has to return a deferred value with a map associating batch elements with their result. Everything that was not resolved will be passed to the original resolution logic.

Note that PureResolvable batches will never be passed to the interceptor.