Expose confirmed server projections through the typed replica client
This commit is contained in:
@@ -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/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user