---
title: Queries
editUrl: https://github.com/Cratis/Arc.TypeScript/edit/main/Documentation/queries/index.md
description: Read application state through read models and their static query methods, snapshot or live, and find the pages for arguments, paging, validation, and transports.
---


A frontend needs lists, lookups, and live views, and each one normally means a route, argument parsing, paging code, and a response shape to keep in step with the client. In Arc, a query is a static method on a read model. Arc supplies the route, binds the arguments, pages and sorts the result, and, for a live query, streams updates to every subscriber.

```mermaid
flowchart LR
    Client -->|GET or QUERY| Route[Arc route]
    Route --> Checks[Authentication, authorization, validation]
    Checks --> Perform[Query method]
    Perform --> Render[Renderers, interceptors, paging and sorting]
    Render --> Result[QueryResult]
    Result --> Client
```

## A query

```typescript
@readModel()
export class TaskItem {
    @field(TaskId) id!: TaskId;
    @field(TaskTitle) title!: TaskTitle;

    @query(service(Tasks))
    static allTasks(tasks: Tasks): TaskItem[] { return tasks.all(); }
}
```

This excerpt is from the [Tasks sample read model](https://github.com/Cratis/Arc.TypeScript/blob/main/Samples/Tasks/Features/Tasks/Listing/Listing.ts). `GET /api/tasks/listing/all-tasks` answers with a query result whose `data` holds the tasks.

A read model here is a class describing the shape of what you return. Where the data comes from is your choice: an in-memory service, [MongoDB](/arc/backend/typescript/mongodb/), [SQL with Drizzle](/arc/backend/typescript/sql/), or a Chronicle projection.

## Find your way

| Page | Use it when you want to |
| --- | --- |
| [Model-bound queries](/arc/backend/typescript/queries/model-bound/) | Declare read models, query methods, and their parameters |
| [Query arguments](/arc/backend/typescript/queries/model-bound/query-arguments/) | Bind named, optional, and repeated arguments from the query string |
| [Paging and sorting](/arc/backend/typescript/queries/model-bound/paging/) | Page and sort in memory, or return a page your data source cut |
| [Query validation](/arc/backend/typescript/queries/validation/) | Validate arguments together with `QueryValidator` |
| [Query pipeline](/arc/backend/typescript/queries/query-pipeline/) | Understand the order of checks and result processing |
| [Using the HTTP QUERY method](/arc/backend/typescript/queries/using-the-http-query-method/) | Send structured arguments in a body |
| [Observable queries](/arc/backend/typescript/queries/observable-queries/) | Serve a snapshot and live updates from the same route |
| [Subscribe to an observable query](/arc/backend/typescript/queries/subscribing-to-observable-queries/) | Receive updates over SSE, a WebSocket, or the `@cratis/arc` client |
| [Multiplexed observable queries](/arc/backend/typescript/queries/observable-query-demultiplexer/) | Share one WebSocket or SSE connection across many subscriptions |
| [Observable emission guards](/arc/backend/typescript/queries/observable-query-emission-guards/) | Re-check access for every emission |
| [Query health](/arc/backend/typescript/queries/query-health/) | Inspect the caller's own hub connections |
| [Using observable queries with curl](/arc/backend/typescript/queries/using-observable-queries-with-curl/) | Explore a live query from a terminal |
| [Query renderers](/arc/backend/typescript/queries/renderers/) | Turn a provider-owned value into data or a page |
| [Read-model interception](/arc/backend/typescript/queries/read-model-interception/) | Transform read-model instances before they reach the wire |
