@graphium/cli
v0.1.0-rc.1
Published
CLI tool for Graphium graph OGM
Downloads
76
Maintainers
Readme
@graphium/cli
Graph-native OGM with multiple graph DB backends
Explicit persistence model — no Proxy magic, no N+1 footguns
@graphium/cli is the graphium command-line tool for managing entity
schemas and database migrations.
What's new in 0.4
graphium migrate:diff(Phase 4.1) — emits a reviewable{timestamp}-auto-diff.cypherfile by comparing decorator metadata against the live database schema.--allow-destructiveflag enables DROP/MODIFY statements; without it those entries are commented out and the command exits with code1so CI catches them.- Production gate: when
NODE_ENV=production,--allow-destructiverequires an explicitGRAPHIUM_ALLOW_DESTRUCTIVE_PROD=trueenv opt-in (otherwise throwsConfigurationError). - Currently wired for the
neo4jbackend; other backends throwNotImplementedErrorin 0.4.
Install
pnpm add -D @graphium/cliOr install globally:
pnpm add -g @graphium/cliSetup
graphium initCreates a graphium.config.ts file in the current directory. For Memgraph:
graphium init memgraphExample generated config:
import type { GraphiumConfig } from '@graphium/cli'
const config: GraphiumConfig = {
backend: 'neo4j',
connection: 'env',
entities: ['./src/entities/**/*.ts'],
migrationsPath: './migrations',
}
export default configCommands
| Command | Description |
| -------------------------------- | ---------------------------------------------------------------------------- |
| graphium init | Create graphium.config.ts (Neo4j) |
| graphium init memgraph | Create graphium.config.ts (Memgraph) |
| graphium migrate:create <name> | Create a new migration file |
| graphium migrate:up | Run all pending migrations |
| graphium migrate:down [steps] | Revert migrations (default: 1) |
| graphium migrate:status | Show migration status |
| graphium migrate:preview | Preview pending migration statements |
| graphium migrate:diff | Emit schema diff between entities and live DB (--allow-destructive opt-in) |
| graphium schema:validate | Validate entity decorator metadata |
| graphium schema:inspect | List registered entities and relationships |
| graphium --version | Print the CLI version |
Entity Loading
Entities are loaded at runtime via jiti so
TypeScript entity files are imported directly without a separate compile step.
Glob patterns in entities are resolved with tinyglobby.
Connection
Set connection: 'env' in the config to read connection details from
environment variables. For Neo4j: NEO4J_PASSWORD is required;
NEO4J_USERNAME defaults to neo4j. For Memgraph: set both
MEMGRAPH_USERNAME and MEMGRAPH_PASSWORD.
Peer Dependencies
@graphium/neo4j and @graphium/memgraph are optional peer dependencies.
Install the one that matches the backend value in your config.
