graphpc
v0.9.4
Published
Type-safe graph API for TypeScript. Like GraphQL, without the query language.
Downloads
276
Readme
GraphPC
GraphPC is a TypeScript RPC framework where your API is a typed object graph.
Define your API as classes, navigate it as objects on the client, and keep end-to-end types without code generation.
Why GraphPC
- Typed graph traversal: model API relationships as
@edges between classes. - Simple execution model: edge navigation is local; data reads and methods are remote.
- No codegen: client types flow from
createClient<typeof server>(...). - Capability-shaped authorization: graph reachability can define authorization boundaries.
- SSR + hydration support: use the same graph client model across server and browser.
Mental Model in 30 Seconds
@edge: navigate to another node (local, synchronous path building)@method: run an operation and return data (RPC)@stream: push server data to the client (async iteration)await node: load a node's data fields (public properties + getters, including inherited ones)
Server shape:
import { Node, edge, method } from "graphpc";
import { z } from "zod";
class Post extends Node {
title = "Hello";
@method(z.string())
async updateTitle(next: string): Promise<void> {
this.title = next;
}
}
class PostsService extends Node {
@edge(Post, z.string())
get(id: string): Post {
return new Post();
}
}
class Api extends Node {
@edge(PostsService)
get posts(): PostsService {
return new PostsService();
}
}Client behavior:
const post = client.root.posts.get("42"); // local path navigation
const { title } = await post; // RPC data fetch
await post.updateTitle("New"); // RPC method callStart Here
- Getting Started
- Mental Model
- Decorators
- Identity and References
- Runtime Lifecycle and Resilience
- Authentication and Authorization
- Common Patterns
- Documentation Index — full reading guide
Install
# bun
bun add graphpc zod
# npm
npm install graphpc zod
# pnpm
pnpm add graphpc zodGraphPC works with any Standard Schema validator (zod, valibot, arktype, etc.).
Human ideas, AI code
GraphPC was designed by a human (Hi, I'm Carl!). The docs, code, and tests were largely produced with AI assistants, including Claude and Codex, then reviewed and edited by humans.
