Backend Integration
Generated query proxies connect TypeScript callers to Arc backend query endpoints without handwritten request URLs or response deserialization. Use the proxy that matches the backend query declaration, then configure its destination and supply its typed arguments.
Backend Query Styles
Section titled “Backend Query Styles”Arc supports both backend styles:
- Controller-based Queries use ASP.NET Core controllers and routing.
- Model-bound Queries put discoverable query methods on a read model.
The backend chooses the route, parameters, and returned model. The proxy generator reads the compiled application and emits the corresponding route, parameter descriptors, model type, and one-shot or observable client. These are endpoint contracts, not a requirement to use Chronicle or event sourcing.
Calling a generated query
Section titled “Calling a generated query”For example, Arc’s query-showcase sample declares a model-bound ById(int id) query returning one ShowcaseItem. Its generated ById proxy extends QueryFor<ShowcaseItem, ByIdParameters> and declares the route /api/features/query-showcase/by-id.
With those generated files available to your frontend:
import { ById } from './Features/QueryShowcase/ById';
const query = new ById();query.setOrigin('https://api.example.com');const result = await query.perform({ id: 42 });
if (result.isSuccess) { console.log(result.data.name);}The import path depends on your configured proxy output folder. perform(...) returns a query-result envelope, not the model alone: inspect success, authorization, validation, and exception information before using the data. Required request arguments are checked before a request is sent. Ordinary queries default to HTTP GET; the core request builder places arguments not consumed by route placeholders in the query string.
Proxy Generation Benefits
Section titled “Proxy Generation Benefits”Regenerate proxies when backend routes, argument types, or result shapes change; do not repair generated files by hand. Configure apiBasePath only for an additional deployment prefix, not a duplicate of the generated route. If a gateway selects a service through a header, set microservice separately.
For setup and configuration, see Backend Proxy Generation. Observable queries use the streaming client contract instead of a one-shot perform call; see Observable Queries.
React Layer
Section titled “React Layer”React hooks provide lifecycle and state handling on top of the same contracts. See React Queries rather than starting requests directly during component rendering.