# @monarcode/effetch-query (https://effetch-query.monarcode.dev/docs/reference/core)

`@monarcode/effetch-query` is the core entry point. It has no framework in it, so it works in React, React Native and code with no UI at all. It exports six namespaces, each with a page of its own, and two names at the top level. Import what you use:

```ts
import {
  Entity,
  InfiniteQuery,
  Mutation,
  Query,
  QueryClient,
  QueryFailure,
  Signals,
  type Register,
} from "@monarcode/effetch-query";
```

## Namespaces

- [`Query`](https://effetch-query.monarcode.dev/docs/reference/query): defining queries, keys and targets, and the cache from Effect.
- [`InfiniteQuery`](https://effetch-query.monarcode.dev/docs/reference/infinite-query): queries that load a list one page at a time.
- [`Mutation`](https://effetch-query.monarcode.dev/docs/reference/mutation): defining and running mutations.
- [`Entity`](https://effetch-query.monarcode.dev/docs/reference/entity): records whose every cached copy a write updates.
- [`QueryClient`](https://effetch-query.monarcode.dev/docs/reference/query-client): the client, its options and hooks, and server rendering.
- [`Signals`](https://effetch-query.monarcode.dev/docs/reference/signals): where a client hears about focus and reconnects.

Its two top-level names follow, grouped by the guide that covers them, each with its
docs. Your editor shows the same docs, with an example, when you hover the
name.

## Register your services

Guide: [1. Describe your API](https://effetch-query.monarcode.dev/docs/getting-started#1-describe-your-api).

### Register

Declares the services your queries and mutations run with. Augment it once, next to your composition root, and every definition, client hook and `QueryClient.runPromise` is typed against it:

- [`QueryClient.make`](https://effetch-query.monarcode.dev/docs/reference/query-client#make) requires a layer or a runtime that provides these services.
- An Effect that needs a service outside them doesn't compile.

Without the augmentation, [`QueryClient.Services`](https://effetch-query.monarcode.dev/docs/reference/query-client#services) is `never`, so anything that needs a service fails to compile.

## Suspense and error boundaries

Guide: [Suspense and error boundaries](https://effetch-query.monarcode.dev/docs/react/suspense).

### QueryFailure

Thrown by `useSuspenseQuery` and `useSuspenseInfiniteQuery` (from `@monarcode/effetch-query/react`) to the nearest error boundary when a query fails with no earlier value to show (a failed refetch keeps showing the last success instead), or when a reader's `select` throws. It carries the query, so the boundary can refetch it with `useResetQueryFailure`, and the full `Cause`. Tell it from other errors with `QueryFailure.is`. Code outside React never sees it: there, a query's failure keeps its own error type.