Skip to content
TypeWire

@tahanabavi/typefetch-query-core

v1.1.0

Framework-agnostic query engine for TypeFetch contracts (cache, dedup, staleness, mutations, invalidation).

A framework-agnostic query engine for TypeWire contracts — cache, dedup, staleness, mutations, and declared invalidation — over HTTP and WebSocket alike, because it needs nothing but a callable endpoint carrying a stable id.

It imports no framework and no transport. Pair it with an adapter (@tahanabavi/typefetch-react) for hooks, or drive it directly through its Observable contract (subscribe / getSnapshot) — the same seam a Vue or Angular adapter would bind.

bash
pnpm add @tahanabavi/typefetch-query-core

What's in it

  • Cache & dedup — one entry per endpoint + input; concurrent fetchers for the same key share a single request.

  • StalenessstaleTime / gcTime; a stale entry refetches on the next observe, an unused one is garbage-collected.

  • Mutations & declared invalidation — the relations map (static or a function of { variables, data }), plus per-call invalidates — never a hand-written key.

  • Retry — configurable retry / retryDelay on queries and mutations, with a CancelledError for aborted in-flight work.

  • Observable contract — every observer, and the cache itself, expose subscribe / getSnapshot, so useSyncExternalStore (or any framework's equivalent) binds without a shim.

  • FiltersinvalidateQueries / refetchQueries / cancelQueries / removeQueries take { endpointId, input, predicate }.

  • A cache event busclient.subscribe(event => …) powers devtools, persistence, and logging without wrapping the engine.