Endpoints

Types

Field paths, the context, rows, views and summaries are typed from your schema and relations.

The resource types every field path it can reach, like status, customer.name or orderLines.product.category. The scope builder, request types and generated schemas all use them, so a typo is a type error.

Type a path below. The suggestions and errors are the ones TypeScript gives you.

Your editororders.controller.ts
await orders.query({ request: {
filters: [{ type: "condition",
key: "",
operator: "is", value: /* string */ }],
} });
orderLines.product.category is a valid filter path.value is typed as string

The scope builder

f in query.scope only accepts paths from the resource's relations. Hover a path to see its type:

engine
.
defineResource
("orders", {
relations
: {
customer
: true,
orderLines
: {
with
: {
product
: true } },
},
query
: {
scope
: (
f
,
ctx
) =>
f
.
and
([
f
.
is
("customer.orgId",
ctx
.
orgId
),
f
.
isNot
("status", "archived")]),
}, });

Completion through relations

Type a prefix and the editor offers the valid continuations:

engine
.
defineResource
("orders", {
relations
: {
customer
: true,
orderLines
: {
with
: {
product
: true } },
},
query
: {
scope
: (
f
,
ctx
) =>
f
.
is
("orderLi
nes.",
ctx
.
orgId
),
}, });

A path that doesn't exist

engine
.
defineResource
("orders", {
relations
: {
customer
: true },
query
: {
scope
: (
f
,
ctx
) =>
f
.
is
("nonExistentField",
ctx
.
orgId
),
Argument of type '"nonExistentField"' is not assignable to parameter of type 'QueryFieldPath<ModelSchema<{ customers: PgTableWithColumns<{ name: "customers"; schema: undefined; columns: { id: PgBuildColumn<"customers", SetIsPrimaryKey<SetHasDefault<PgUUIDBuilder>>, { ...; }>; name: PgBuildColumn<...>; orgId: PgBuildColumn<...>; }; dialect: "pg"; isAlias: false; }>; orderLines: PgTableWithColu...'.
}, });

The context

.withContext<T>() types the context of every call and the ctx of the scope:

const 
engine
=
createQueryEngine
({
db
,
schema
,
relations
}).
withContext
<{
orgId
: string;
userId
: string;
}>();
engine
.
defineResource
("orders", {
query
: {
scope
: (
f
,
ctx
) =>
f
.
is
("status",
ctx
.
orgId
),
}, });

Types for your client

TypeWhat it is
typeof resource.$infer.views.<name>The row type of a view.
typeof resource.$infer.summaryThe summary's result.
QueryRequestInputThe request a client may send, with optional fields.
z.infer<typeof responseSchema(...)>The response, when you validate it with Zod.

Export them from your server package, or share the request schema, so the client builds requests against the same contract. See the types reference.

Copyright © 2026