Cobalt is a TypeScript framework for building type-safe APIs that aims to combine GraphQL’s flexible data selection with the quick development experience of tRPC, without requiring developers to write GraphQL manually. Resolver files define backend logic, and Cobalt infers the schema from that code and generates a typed client SDK. Developers can use the SDK’s simple default mode to fetch full objects or provide a callback to select only the fields they need. The framework presents TypeScript as the single source of truth, avoiding separately maintained interfaces, schemas, resolver declarations, and client code-generation steps.
Its case for Cobalt contrasts it with three approaches: REST can require many endpoints and return more data than clients need; pure GraphQL can duplicate definitions across types, schemas, and queries; and tRPC can tightly couple client and server code, making later shifts to microservices or public APIs harder. Cobalt claims to offer a flexible schema contract while keeping types connected across the network boundary. It also emphasizes reduced boilerplate: developers write application logic without separate routers, controllers, adapters, or serialization layers. The project further argues that compact, collocated code is easier for people and AI tools to understand, citing a comparison of 13 files and 3.4k tokens for a Cobalt app against 45 files and 11.2k tokens for a typical app.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.