waygraph / reads
Function: reads()
reads(
namespace): <T>() =>ReadNamespace<T>
Defined in: src/engine/read/read-key.ts:52
Declares a read namespace: one type, its property names become key paths, no const per key.
Parameters
namespace
string
Returns
<T>() => ReadNamespace<T>
Example
ts
export const Post = reads("post")<{ title: string; likes: number; comments: { author: string; body: string }[] }>();
Post.likes; // ReadKey<number>, path "post.likes"
Post({ title: ctx.page.text("h1") }); // the spec a Read Block returnsDeprecated
A page's read declares its keys as it reads: definePageBlock({ read: (ctx) => ({ title: ctx.page.text("h1") }) }), then Page.read.title. waygraph upgrade --codemod page-object moves a project.