Omnigraph
Schema

Schema

A .pg file defines your graph's structure — the node types, edge types, interfaces, and constraints that the query engine enforces.

Every Omnigraph repository starts with a schema. The schema is a single .pg file that declares what kinds of entities and relationships exist in your graph, what properties they carry, and what rules apply to the data.

What a .pg file looks like

node Person {
    name: String @key
    age:  I32?
}

node Company {
    name: String @key
}

edge Knows: Person -> Person {
    since: Date?
}

edge WorksAt: Person -> Company

The three declaration kinds

KeywordPurpose
nodeA vertex type with typed properties
edgeA directed relationship between two node types
interfaceA named set of properties that node types can implement

Every node and edge gets its own storage table. Interfaces are compile-time only.

What the schema drives

When Omnigraph opens a repository, it compiles _schema.pg into a catalog:

  1. Typecheck queries — property references, traversal paths, and filter expressions are validated against the declared types.
  2. Create and validate storage — one data table is created per node type and per edge type.
  3. Enforce constraints@range, @check, and edge cardinality annotations are checked at load and mutation time.
  4. Build indices@index and @key annotations cause BTree, inverted (full-text), or IVF-HNSW (vector) indices to be created.

On this page