Skip to content

API reference > @kontsedal/olas-core > QueryEngine

QueryEngine type ​

The query engine — pass one to createRoot to give the root a cache:

ts
createRoot(app, { deps, queries: queryEngine({ defaults: { staleTime: 30_000 } }) })

**Why it is a separate value.** query/client.ts is the largest module in the package. This module is the only one that imports QueryClient by value, so a root built without queries leaves the cache engine, the entry state machine, infinite pagination and the refetch triggers out of the bundle.

**It is a definition, not an instance.** Each root that adopts it gets its own QueryClient, so one engine value can be hoisted to module scope and shared — by several roots, or by a HydrationBoundary that rebuilds its root under StrictMode.

**The client is created eagerly**, inside createRoot, before plugin setup and the controller factory run, so a plugin's setup can already reach the cache. That matters: mutationQueuePlugin replays mutations persisted by a previous session from setup, which is a startup obligation and not a response to anything the current session does.

Signature:

typescript
type QueryEngine = {
  readonly [BRAND]: 'queryEngine';
};

Released under the MIT License.