The IRI of the entity to extract
The RDF dataset to extract from
The JSON Schema defining the structure to extract
Walker options including filter options (select/include/omit)
Optional base IRI for expanding property names (defaults to "http://schema.org/")
Optionalcontext: Record<string, string>Optional prefix mappings for property name expansion
Optionallogger: LoggerOptional logger for debugging (defaults to no-op)
The extracted data as a JavaScript object
// Without type parameter (backward compatible)
const result = extractFromGraph(
"http://example.com/person1",
dataset,
personSchema,
{
includeRelationsByDefault: false,
include: { friends: { take: 10 } },
omit: ["internalId"],
},
"http://schema.org/",
{ dc: "http://purl.org/dc/elements/1.1/" }
);
// With Zod type inference for type safety
import { z } from 'zod';
const zodSchema = z.object({
name: z.string(),
friends: z.array(z.object({ name: z.string() }))
});
type Person = z.infer<typeof zodSchema>;
const result2 = extractFromGraph<Person>(
"http://example.com/person1",
dataset,
personSchema,
{
include: { friends: { take: 10 } } // Type-safe: only valid keys allowed
}
);
Extracts data from an RDF graph according to a JSON Schema
This is the main entry point for the new extractor implementation. It automatically normalizes the schema if needed, then uses the normalized schema structure to guide extraction from the graph.
Key improvements over the legacy implementation: