For posts with an authorId string field, declare an author relationship alongside the post schema. The authors collection contains entries with a name field.
relationships: {
author: {
collection: "authors",
type: "one",
from: "authorId",
to: "id",
referenceSide: "from",
},
}
Load related entries
Select fields independently at every level:
const posts = await content
.query("posts")
.select("id", "title")
.with("author", (author) => author.select("name"))
.all();
ContentGraph checks authored references during preparation. Dangling references, ambiguous matches, and invalid singular cardinality fail validation.
Many relationships support per-parent filtering, ordering, and pagination. A singular relationship can be filtered and returns null when its target is excluded. See querying related content for the equivalent object query.