tRPC vs GraphQL
Type-safe APIs.
Overview
tRPC and GraphQL are two leading type-safe API styles with different trade-offs. tRPC is TypeScript-native (end-to-end type safety via TS inference, no schema language to maintain, server-and-client must both be TypeScript); GraphQL is schema-first (cross-language schema, federation across services, mature ecosystem of clients and tooling). The right answer depends on whether the stack is TypeScript-only or polyglot.
- tRPC: TypeScript-native. End-to-end type safety via TS inference. No schema language, no codegen. Default for TS-only stacks.
- GraphQL: schema-first plus cross-language. SDL schema, broad client ecosystem, federation across services. Default for polyglot or federated APIs.
- Operational fit per team. TypeScript-only stacks bias toward tRPC; polyglot or federated stacks bias toward GraphQL.
- Per-API choice. Different APIs may pick differently. Document the rationale per API.
The approach
Workload-driven choice, per-team operational fit considered, documented rationale per API. The discipline is making the API style choice once with a written reason rather than mixing both styles within the same surface area.
- Workload-driven. Style per API. Reality drives the answer.
- tRPC for TypeScript-only stacks. Internal APIs between TS server and TS client. Default when both ends are TypeScript.
- GraphQL for cross-language or federated APIs. Public APIs, polyglot clients, federated micro-frontends. Default when SDL matters.
- Operational fit plus documented rationale. Team workflow considered; per-API rationale captured. Future migrations have a paper trail.
Why this compounds
The right API style compounds across years. API patterns and team expertise align with the style; cross-API tooling (client codegen, schema versioning, observability) gets built once and reused. By year two the style choice is automatic per API.
- Better operational fit. Style matches team and stack. Velocity stays high.
- Workload-driven decisions. Replaces tribal preference with documented rationale. Quality of choice improves.
- Better engineering velocity. Right style means types flow cleanly across the wire. Iteration speed increases.
- Year-one investment, year-two habit. First API choice is the investment; subsequent APIs inherit the patterns.