Registry / database / grafio

grafio

JSON →
library7.15.1jsnpmunverified

Grafio (v7.15.1) is a high-performance, in-memory graph database for Node.js with native Cypher query support and pluggable storage backends (in-memory built-in, MongoDB via separate package). It supports BFS/DFS traversal, atomic transactions with automatic rollback, DAG validation, topological sort, and Mermaid graph export. Key differentiators: Cypher-native query engine compatible with OpenCypher, smart LRU/LFU/FIFO caching with budget enforcement, and TypeScript-first design. Release cadence: irregular, with active development.

npm install grafio
INSTALL
IMPORT
SIG · GRAFIO
G
grafio
databasejavascriptv7.15.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CypherEngine
✓ import { CypherEngine } from 'grafio'
✗ const CypherEngine = require('grafio').CypherEngine;
ESM-only package; CommonJS require works but incorrect destructuring pattern often causes errors
InMemoryGraphFactory
✓ import { InMemoryGraphFactory } from 'grafio/storage'
✗ import { InMemoryGraphFactory } from 'grafio'
InMemoryGraphFactory is exported from a subpath 'grafio/storage', not the main entry
Graph
✓ import type { Graph } from 'grafio'
✗ import { Graph } from 'grafio'
Graph is a TypeScript interface; use type import for type-only uses, but value import works if using runtime features (rare)

Quick start showing in-memory graph creation, Cypher EXECUTE for CREATE and MATCH, and querying relationships.

import { CypherEngine } from 'grafio'; import { InMemoryGraphFactory } from 'grafio/storage'; const factory = new InMemoryGraphFactory(); const graph = factory.forGraph('social-network'); const cypher = new CypherEngine(graph); cypher.execute(` CREATE (a:Person {id: 'alice', name: 'Alice', age: 30}), CREATE (b:Person {id: 'bob', name: 'Bob', age: 25}), CREATE (c:Person {id: 'charlie', name: 'Charlie', age: 35}) `); cypher.execute(` MATCH (a:Person {id: 'alice'}), (b:Person {id: 'bob'}) CREATE (a)-[:KNOWS {since: 2020}]->(b) `); cypher.execute(` MATCH (b:Person {id: 'bob'}), (c:Person {id: 'charlie'}) CREATE (b)-[:KNOWS {since: 2019}]->(c) `); const friends = cypher.execute('MATCH (p:Person)-[:KNOWS]->(friend:Person) RETURN p.name as name, friend.name as friend'); console.log(JSON.stringify(friends, null, 2));
Debug
Known issues
gotchaSubpath imports: 'grafio/storage' must be imported separately for storage factories; main entry does not re-export them.
fix
Use 'import { InMemoryGraphFactory } from 'grafio/storage'' instead of from 'grafio'.
affects: >=7.0.0
breakingBreaking: In v7, the storage API was refactored; GraphFactory.createGraph(id) replaced by factory.forGraph(id).
fix
Update calls: factory.forGraph(id) instead of factory.createGraph(id).
affects: >=7.0.0
gotchaCypherEngine.execute() returns plain objects, not Records. Do not expect GraphResult or similar types.
fix
Use generic result type: Record<string, unknown>[] or assert with Zod.
affects: >=7.0.0
deprecatedThe 'query' method on CypherEngine is deprecated in favor of 'execute'. Using 'query' may be removed in future versions.
fix
Replace .query() calls with .execute().
affects: >=7.10.0
Errors
Common errors & fixes
Error: Cannot find module 'grafio/storage'
Subpath imports not resolved (common with bundlers or older Node versions).
fix
Ensure Node.js version >= 14 (or use bundler that supports exports field). For CommonJS, use 'grafio/storage' with require but ESM is recommended.
CypherEngine is not a constructor
Importing CypherEngine incorrectly (e.g., default import vs named import).
fix
Use named import: import { CypherEngine } from 'grafio';
TypeError: graph.forGraph is not a function
Using old API from v6 where factory.createGraph existed.
fix
Use factory.forGraph(id) (v7+).
Upgrade
Version history
7.15.1latest on npm
Audit
Dependencies
ioredisoptionalPeer dependency for Redis storage backend (optional, not required for in-memory)
Agent activity
13 hits · last 30 days
node
12
Resources
packagegrafio ↗
grafio — npm install grafio · libregistry