Skip to Content
Schema DSL

Schema DSL

Use import { parseSchema, parseSchemaFile, printSchemaDocument, … } from "cyphra" (or @cyphra/schema) for programmatic APIs. parseSchemaFile(path) loads a UTF-8 .cyphra file from disk (Node.js).

Define nodes, relationships, and decorators in schema.cyphra:

node User { id String @id @default(cuid()) email String @unique name String @index } node Post { id String @id title String author User? @relationship(type: "AUTHORED", direction: IN) } relationship Follows { type "FOLLOWS" from User to User since DateTime @index requestId String @unique }

Decorators (V1): @id, @unique, @index (Neo4j 5+ range index: on nodes via (n:Label), on rich relationships via ()-[r:TYPE]-()), @default(…), @relationship(…). On nodes, you cannot combine @index with @id or @unique on the same field (those constraints already imply an index). On relationship models, @unique maps to a relationship property uniqueness constraint (Neo4j 5.7+); @id is not allowed on relationship fields.

The parser produces an AST used by cyphra push, cyphra generate, and programmatic APIs. Use printSchemaDocument from @cyphra/schema (or cyphra schema print) to emit a canonical .cyphra text for diffs and reviews—comments are not preserved.

Last updated on