claro.engine

Main resolution and engine logic.

Claro’s resolution engine is powerful and customizable, allowing for flexible introspection and manipulation of every resolution run.

See the Engine documentation for details and examples.

default-impl

The default deferred implementation used for resolution.

default-opts

The default engine options.

engine

(engine)(engine opts)(engine impl opts)

Create a new resolution engine, based on the following options:

  • :env: a value that is passed as the env parameter to Resolvables’ resolve! and resolve-batch! functions (default: {}),
  • :adapter: a function that will be called to run calls to resolve! and resolve-batch!,
  • :selector: a claro.engine.selector/Selector implementation used during each iteration to decide what to resolve next,
  • :max-cost: a value describing the maximum resolution cost for each run, causing the engine to throw an IllegalStateException (default: 32) if exceeded,
  • check-cost?: a flag enabling/disabling cost protection (default: true).

The resulting value’s resolution behaviour can be wrapped using claro.engine/wrap.

impl

(impl engine)

Return the given engines deferred implementation.

multi-engine

(multi-engine)(multi-engine base-engine)

Create a resolution engine that takes a seq of values and resolves them in-order and independently using the optionally given base engine.

This is especially useful when resolving multiple mutations since the cache will be reset between runs.

run!

(run! value)(run! opts value)

Resolve the given value using an engine created on-the-fly. See claro.engine/engine for available options. Immediately returns a deferred.

run!!

(run!! value)(run!! opts value)

Resolve the given value using an engine created on-the-fly. See claro.engine/engine for available options. Blocks until the resolved value has been obtained.

wrap

(wrap engine wrap-fn)

Wrap the engine’s complete resolver function using the given wrap-fn. The resolution results will be wrapped as trees. See wrap-transform and wrap-pre-transform for access to the transformed and raw results.

wrap-pre-transform

added in 0.2.8

(wrap-pre-transform engine wrap-fn)

Wrap the given engine’s resolver (before transformation) using the given wrap-fn.

wrap-transform

added in 0.2.8

(wrap-transform engine wrap-fn)

Wrap the given engine’s resolver (after transformation but before tree wrapping) using the given wrap-fn.