The JSON Schema to prepare
Selection set for projecting properties
A TraversalSchema (dereferenced then projected)
const traversal = buildTraversalSchema(schema, {
include: { tags: { take: 10 } },
includeRelationsByDefault: false
});
// With Zod type inference for type safety
import { z } from 'zod';
const zodSchema = z.object({
name: z.string(),
tags: z.array(z.object({ label: z.string() }))
});
type MyType = z.infer<typeof zodSchema>;
const traversal2 = buildTraversalSchema<MyType>(schema, {
include: { tags: { take: 10 } } // Type-safe: only valid keys allowed
});
Prepare a JSON Schema for graph traversal / SPARQL CONSTRUCT generation.
Two phases (intentionally separate concerns):
$reftargets (dereferenceSchema). This is denormalization in the database sense: factoreddefinitionsare duplicated at each use site so downstream code can walk.propertieswithout resolution.projectSchema:select/include/omit/where).Prefer calling the phases separately when you need only one of them. Reserve "normalize" / "canonicalize" for true normal-form transforms such as
canonicalizeSchemaForFingerprintin@graviola/json-schema-utils.