Compile and execute bounded GraphQL replica admission

This commit is contained in:
Timothy J. Aveni
2026-09-20 03:04:44 -07:00
parent d9bd5b2800
commit 3f1976815f
6 changed files with 73 additions and 1 deletions
+2
View File
@@ -2,6 +2,7 @@
import { mkdir, writeFile } from "node:fs/promises";
import { loadReaderWorkspace } from "./reader-fixture.js";
import { compileKernelProgram } from "../src/execution-world/kernel.js";
import { compileQueryProgram } from "../src/execution-world/queries.js";
import { compileExecutionPlan } from "../src/execution-world/plan.js";
import { generatePortableTypeScriptBindings } from "../src/bindings/portable.js";
import { generatePortableClientBindings } from "../src/bindings/portable-client.js";
@@ -15,6 +16,7 @@ for (const target of ["browser", "server"])
);
await writeFile("dist/portable-reader/plan.json", JSON.stringify(plan));
await writeFile("dist/portable-reader/kernel.json", JSON.stringify(compileKernelProgram(plan)));
await writeFile("dist/portable-reader/queries.json", JSON.stringify(compileQueryProgram(plan)));
await writeFile("dist/portable-reader/client.ts", generatePortableClientBindings(plan, { target: "browser" }));
const serviceWorkspace = structuredClone(plan.definition.workspace);
serviceWorkspace.atoms = [];
+1
View File
@@ -77,6 +77,7 @@ revision "package:reader-runtime@1" {
}
query HighlightScope id "reader:highlight-scope" root workspace HighlightData document "queries/highlight-scope.graphql" operation "HighlightScope" { view Comment as CommentData; replica; max rows 200; }
query HighlightWindow id "reader:highlight-window" root workspace HighlightData document "queries/highlight-window.graphql" operation "HighlightWindow" { view Comment as CommentData; replica; max rows 200; }
query HighlightList id "reader:highlight-list" root workspace HighlightData document "queries/highlight-list.graphql" operation "HighlightList" { view Comment as CommentData; local from HighlightScope; max rows 200; watch; }
query HighlightEditorInputs id "reader:editor-inputs" root HighlightData document "queries/editor-inputs.graphql" operation "HighlightEditorInputs" { view Comment as CommentData; replica; max rows 1; }
query HighlightEditorView id "reader:editor-view" root HighlightData document "queries/editor-view.graphql" operation "HighlightEditorView" { view Comment as CommentData; local from HighlightEditorInputs; max rows 1; watch; }
@@ -0,0 +1,8 @@
query HighlightWindow($color: String!) {
root {
objects(first: 2, where: {color: {eq: $color}}, orderBy: {range: {start: ASC}}) {
entries { key node { _qx {ref} color range {sourceRevision start end} } }
pageInfo { hasNextPage endCursor }
}
}
}
+1 -1
View File
@@ -8,7 +8,7 @@ test("complete reader contracts compose factories, portable selectors, CRDT edit
assert.equal(workspace.constructors.length, 0);
assert.equal(workspace.atoms.length, 3);
const linked = linkQueries(workspace);
assert.equal(linked.length, 6);
assert.equal(linked.length, 7);
assert.equal(linked.filter((q) => q.checked.declaration.placement?.kind === "local").length, 3);
const screen = linked.find((q) => q.checked.declaration.displayName === "ReaderScreen")!;
assert.ok(screen.fields.some((f) => f.memberId === "highlight:excerpt" && f.binding.kind === "package"));