Implement progressive query admission, session boundaries and event-driven Studio observations
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { queryWorkspaceFixture } from "./fixtures/query-workspace.js";
|
||||
import { compileQuery } from "../src/query/compile.js";
|
||||
import { queryTreeProjections } from "../src/query/tree.js";
|
||||
import { linkQueries } from "../src/query/link.js";
|
||||
import { compileExecutionPlan } from "../src/execution-world/plan.js";
|
||||
|
||||
export async function queryTreeFixture() {
|
||||
const fixture = await queryWorkspaceFixture({ live: true, snapshot: true });
|
||||
const declaration = {
|
||||
...fixture.pkg.queries!.find((query) => query.id === "upcoming")!,
|
||||
id: "tree",
|
||||
displayName: "Tree",
|
||||
operation: "Tree",
|
||||
placement: { kind: "replica" as const },
|
||||
fragments: [],
|
||||
};
|
||||
const checked = await compileQuery(
|
||||
declaration,
|
||||
fixture.interfaces,
|
||||
async () => `query Tree($first:Int!, $details:Boolean!) {
|
||||
root {items(first:$first) {entries {node {
|
||||
...Heading @boundary(name:"basic") ...Details @boundary(name:"details") @include(if:$details)
|
||||
assignee {...Person @boundary(name:"person")}
|
||||
}}}}
|
||||
} fragment Heading on TaskFacts {title} fragment Details on TaskFacts {rank done}
|
||||
fragment Person on PersonFacts {name}`,
|
||||
);
|
||||
const projections = queryTreeProjections(checked);
|
||||
fixture.pkg.queries = [declaration, ...projections.map((query) => query.declaration)];
|
||||
fixture.pkg.checkedQueries = [checked, ...projections];
|
||||
// Workspace imports retain the checked Package by value in the assembler.
|
||||
const imported = fixture.workspace.packageImports.find((pkg) => pkg.revisionId === fixture.pkg.revisionId)!;
|
||||
imported.queries = fixture.pkg.queries;
|
||||
imported.checkedQueries = fixture.pkg.checkedQueries;
|
||||
fixture.workspace.linkedQueries = linkQueries(fixture.workspace);
|
||||
return { ...fixture, plan: compileExecutionPlan(fixture.workspace) };
|
||||
}
|
||||
Reference in New Issue
Block a user