release now, official release at the end of this month Available as epub and pdf files (free updates) Spin-off from the London Tech Talk podcast community 3
Rediscover GraphQL: Straightforward queries and granular mutations 3. Co-Located Backend Architecture with Route Handlers 4. Recap: GraphQL can still be an option 5
Server Component Era RSC enables server-side data fetching per component Prior to RSC... Next.js pages router data fetching was page-level fetch all data in a single query Recent argument: "GraphQL is less necessary for RSC" My Realization GraphQL benefits go beyond fetching all data at once Still useful for contract + ergonomics 6
ID!) { user(id: $id) { name posts { title content } } } Query resources as a graph and traverse relations Discoverability via schema/introspection (when enabled) + dev tooling like GraphiQL 7
PATCH often leads to broad input shapes Resource-oriented endpoints carry big responsibility APIs often consolidate updates into broader endpoints More business logic on the client 8
$title: String!) { updatePostTitle(id: $id, title: $title) { post { id title } } } Advantages: RPC-style mutations make intent explicit Business logic surfaces at the interface level First-class typed arguments, discoverability, consistent ergonomics 9
Handlers Server-side execution accessed like a backend API App Router → Route Handlers Pages Router → API Routes Growing Trend Building Next.js apps without a separate backend service using Route Handlers 10
GitHub repository template: GraphQL + Route Handlers https://github.com/KentaKudo/next-graphql-handler Note: This template demonstrates the core concepts and is not intended for production; add auth, error handling, etc. 11
createYoga } from "graphql-yoga"; import { schema } from "./schema"; const { handleRequest } = createYoga({ graphqlEndpoint: "/api/graphql", fetchAPI: { Response }, schema, }); export { handleRequest as GET, handleRequest as POST }; For Apollo Server → @as-integrations/next 12
Pattern RSC enables co-located fetching, but you can still benefit from: Typed, discoverable, stable contract (GraphQL schema) Powerful combination: Flexible graph queries & ergonomic mutations (RPC- style) Co-Located Architecture: Next.js + GraphQL + Route Handlers Bottom Line RSC changes where you fetch, not what your interface contract should be 18
→ Yoga is framework-agnostic; only the adapter changes → Just hook the Yoga instance into Express, Hono, etc. → Keep React/Next.js-specific code in the binding layer 21
→ Code is the source of truth When to choose: Great DX in TypeScript mono-repo Schema-first Write schema, generate resolver skeleton → Schema is the source of truth When to choose: Language-agnostic teams / schema governance My Preference: Code-first with Pothos Template uses Pothos GraphQL for code-first approach 22