Expose confirmed server projections through the typed replica client

This commit is contained in:
Timothy J. Aveni
2026-09-21 00:27:39 -07:00
parent 08e322e59f
commit b4ac9700c6
5 changed files with 77 additions and 10 deletions
+24
View File
@@ -79,3 +79,27 @@ test("a portable subset of a mixed interface excludes remote dependencies", asyn
selected.operations!.push(operation.id);
assert.throws(generate, /select a portable subset/);
});
test("server projection descriptors are distinct from canonical inputs and have result decoders", async () => {
const { generatePortableClientBindings } = await import("../src/bindings/portable-client.js");
const plan = compileExecutionPlan(await loadReaderWorkspace());
const source = generatePortableClientBindings(plan, { target: "browser" });
const projections = source.slice(
source.indexOf("export const serverProjections"),
source.indexOf("export const results"),
);
assert.match(projections, /ConfirmedColor/);
assert.match(projections, /satisfies ServerProjection/);
assert.match(source.slice(source.indexOf("export const results")), /ConfirmedColor/);
const live = compileExecutionPlan(
await loadReaderWorkspace((name, text) =>
name === "queries/confirmed-color.graphql" ? text.replace("color", "color @live") : text,
),
);
const rejected = generatePortableClientBindings(live, { target: "browser" });
assert.doesNotMatch(
rejected.slice(rejected.indexOf("export const serverProjections"), rejected.indexOf("export const results")),
/ConfirmedColor/,
);
assert.match(rejected, /QUERY_NOT_SNAPSHOT_PROJECTION/);
});