Add queryable capability contracts and checked GraphQL artifacts
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { readFile, realpath } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { loadQxSources, resolveQxSources } from "./source-loader.js";
|
||||
import { compileRepositoryQuery } from "../query/compile.js";
|
||||
import { linkQueries } from "../query/link.js";
|
||||
import {
|
||||
capabilityId,
|
||||
compileWorkspaceRevision,
|
||||
@@ -231,6 +233,16 @@ const createResourceGraphResolver = (quixosCommit: string, resolveResource: Capa
|
||||
}
|
||||
assertImportsMatchLock(manifestPath, compiled.resource.imports, lockResult.lock.resources);
|
||||
if (compiled.resource.kind === "package") {
|
||||
const queryInterfaces = [
|
||||
...(environment.interfaceClosure ?? []),
|
||||
...(compiled.resource.specializations ?? []),
|
||||
];
|
||||
if (compiled.resource.revision.queries?.length)
|
||||
compiled.resource.revision.checkedQueries = await Promise.all(
|
||||
compiled.resource.revision.queries.map((query) =>
|
||||
compileRepositoryQuery(snapshot.directory, query, queryInterfaces),
|
||||
),
|
||||
);
|
||||
let catalogText: string | undefined;
|
||||
try {
|
||||
catalogText = await readFile(path.join(snapshot.directory, "quixos.migrations.json"), "utf8");
|
||||
@@ -389,6 +401,11 @@ export const compileWorkspaceRepository = async (options: {
|
||||
.join("\n")}`,
|
||||
);
|
||||
}
|
||||
const linkedQueries = linkQueries(workspace);
|
||||
if (linkedQueries.length) {
|
||||
workspace.linkedQueries = linkedQueries;
|
||||
checked.plan.source.linkedQueries = structuredClone(linkedQueries);
|
||||
}
|
||||
return {
|
||||
workspace,
|
||||
plan: checked.plan,
|
||||
|
||||
Reference in New Issue
Block a user