zenazn/graphpc

A type-safe graph RPC framework for TypeScript

★ 0Forks 0TypeScriptGitHub ↗Compare

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 call

Start Here

  1. Getting Started
  2. Mental Model
  3. Decorators
  4. Identity and References
  5. Runtime Lifecycle and Resilience
  6. Authentication and Authorization
  7. Common Patterns
  8. Documentation Index — full reading guide

Install

# bun
bun add graphpc zod

# npm
npm install graphpc zod

# pnpm
pnpm add graphpc zod

GraphPC 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.

Contributors

zenazn

Issues