Triamorph Systems

← Engineering Dispatches / Architecture

Backend-for-Frontend (BFF) Pattern: GraphQL vs REST vs tRPC for Multi-Platform Enterprise Applications

By Hammad Haider · 12 min read read

Serving desktop web dashboards and native mobile applications from a single monolithic "one-size-fits-all" REST API creates severe inefficiencies: mobile devices overfetch megabytes of unneeded JSON payloads over cellular connections, while web dashboards require dozens of sequential waterfall HTTP requests to assemble a single screen. The Backend-for-Frontend (BFF) pattern introduces lightweight, client-specific gateway services tailored to the exact data requirements of each user interface.

Architectural Takeaways

  • The BFF pattern decouples frontend development velocity from backend microservice release cycles, preventing API bloat.
  • Use tRPC for single-team TypeScript monorepos (Next.js + React Native) to achieve end-to-end compile-time type safety with zero code generation overhead.
  • Use GraphQL (Apollo Federation) for large multi-team organizations with diverse client teams requiring dynamic field querying across disparate domain services.

1. Why Generic One-Size-Fits-All APIs Fail Multi-Platform Apps

A web dashboard displaying a user profile with 50 analytical widgets requires extensive nested relational data. A mobile notification widget only needs the user’s name and unread badge count. Forcing mobile devices to parse huge JSON payloads consumes battery and degrades render performance.

2. The 3 BFF Archetypes: REST Aggregators, GraphQL & tRPC

REST BFFs provide simplicity and excellent CDN edge caching. GraphQL provides unmatched flexibility for federated multi-team microservices. tRPC offers zero-build type safety across TypeScript full-stack monorepos.

3. End-to-End Type Safety with tRPC in Universal Monorepos

In a Turborepo monorepo sharing code between Next.js web apps and React Native mobile apps, renaming a backend field in tRPC immediately flags TypeScript errors across all client repositories without requiring manual OpenAPI or GraphQL schema generation.

4. Edge Caching & Microservice Resiliency in BFF Layers

Deploying lightweight BFF aggregation functions to Cloudflare Workers allows caching personalized UI fragments close to the user while shielding core backend microservices from sudden traffic spikes.

Read more technical guides on our Dispatches Index →