feat(api-contract): inspect local GraphQL SDL and field references (#9140)

* feat(api-contract): inspect local GraphQL SDL and field references

* fix(api-contract): retain caller metadata and bound selection work
This commit is contained in:
gensokyo-dev authored and GitHub committed 2026-11-06 20:16:31 +08:00
1 parent 14d2c51d85
commit 5303199163
45 files changed
+4204 -99

No files matched your search

+34 -7
View File
@@ -13,8 +13,9 @@ import {
API_CONTRACT_PROVIDER,
} from "../domain/apiContract/apiContract.js";
import {
apiContractViewRequestSchema,
inspectApiContractInputSchema,
apiContractViewSelectionSchema,
apiContractFormatSchema,
apiContractFileBytesSchema,
} from "../domain/apiContract/apiContractQuery.js";
import { withCommandCancellation } from "./commandCancellation.js";
import {
@@ -26,7 +27,7 @@ import {
const deliverySchema = z
.object({
detail: analysisEvidenceDeliveryOptions.detail,
view: apiContractViewRequestSchema.optional(),
view: apiContractViewSelectionSchema.optional(),
})
.superRefine((value, context) => {
if (value.view !== undefined && value.detail !== "summary")
@@ -45,18 +46,28 @@ export const registerApiContractCommand = (
): void => {
cli.command(CLI_COMMANDS.inspectApiContract, {
description:
"Inventory local OpenAPI 3.0/3.1/3.2 JSON declarations offline without resolving references",
"Inspect local OpenAPI JSON or GraphQL SDL declarations and field bindings offline",
args: z.object({
path: localPathStringSchema.describe("Local OpenAPI JSON path"),
path: localPathStringSchema.describe(
"Local OpenAPI JSON or GraphQL SDL path",
),
}),
options: z.object({
...analysisEvidenceDeliveryOptions,
maxFileBytes: inspectApiContractInputSchema.shape.max_file_bytes,
maxFileBytes: apiContractFileBytesSchema,
contractFormat: apiContractFormatSchema
.default("openapi-json")
.describe("Input API contract syntax: OpenAPI JSON or GraphQL SDL"),
operationsPath: localPathStringSchema
.optional()
.describe(
"Local operation/fragment document, only with --contractFormat graphql-sdl",
),
view: z
.string()
.optional()
.describe(
"JSON api-contract page; requires --detail summary and --evidence_output",
"JSON api-contract or graphql-contract page; requires --detail summary and --evidence_output",
),
}),
run: ({ args, options }) =>
@@ -73,12 +84,28 @@ export const registerApiContractCommand = (
await import("../application/apiContract/ApiContractService.js");
return deliverCliAnalysisEvidence({
callerInputPath: args.path,
...(options.operationsPath === undefined
? {}
: {
callerInputPaths: { operations_path: options.operationsPath },
}),
run: () =>
inspectApiContractEvidence(
{
path: absoluteCallerPath(args.path),
format: options.contractFormat,
...(options.operationsPath === undefined
? {}
: {
operations_path: absoluteCallerPath(
options.operationsPath,
),
}),
max_file_bytes: options.maxFileBytes,
detail: "complete",
...(selected.value.view === undefined
? {}
: { view: selected.value.view }),
},
resources,
{ signal },