Skip to content
Home / Migrations / GraphQL (Apollo)tRPC

GraphQL (Apollo) tRPC

hard

tRPC gives type safety without a schema language or codegen. Better fit for full-stack TypeScript apps that don't need a public API.

Estimated: 8-20h · 5 steps
Progress0%
Step 1: Audit GraphQL usage

List all queries, mutations, and subscriptions. Check if any clients outside your TypeScript app consume the API (mobile, third-party). If yes, GraphQL may be the right choice.

Step 2: Install tRPC
npm install @trpc/server @trpc/client @trpc/react-query @tanstack/react-query && npm uninstall @apollo/server graphql
Step 3: Convert resolvers to procedures

GraphQL Query resolvers → tRPC query procedures. Mutations → mutation procedures. Subscriptions → tRPC subscriptions (websocket transport).

Step 4: Replace Apollo Client

Apollo useQuery/useMutation → tRPC's React Query hooks. Apollo cache → TanStack Query cache.

const { data } = trpc.users.list.useQuery()
Step 5: Remove GraphQL schema

Type-safety now comes from TypeScript inference, not the SDL. No more schema.graphql or code generation.

All data fetching works. Types infer correctly. Bundle size reduced.

What this migration involves

Moving from GraphQL (Apollo) to tRPC is rated hard and takes about 8-20h on a typical project. The guide breaks it into 5 steps, 2 of which ship with runnable commands and 1 with a verification check.

FAQ

How long does migrating from GraphQL (Apollo) to tRPC take?

Around 8-20h for a typical project — 5 steps, difficulty rated hard, 2 of them with copy-paste commands.

Is moving from GraphQL (Apollo) to tRPC reversible?

No reverse guide is tracked yet, so treat this as a one-way move and keep a full export of your GraphQL (Apollo) data before you start.

What does tRPC cost compared to GraphQL (Apollo)?

tRPC: open-source from $0/mo, free plan available.