How to build a GraphQL API with Next.js and Vercel
summary
Builds a working serverless GraphQL API inside Next.js API routes, using Apollo Server Micro v3 and micro-cors, with a concrete fix: disable Next.js bodyParser for Apollo. Connects to Fauna DB via its JS driver, generates a Fauna secret, creates a book collection and documents, and queries them with FQL map/paginate/get. Deploys with Vercel CLI so the API becomes a serverless function, verifies queries in Apollo Studio, and inspects function logs on Vercel.
AI-written summary · about
chapters (14)
- 0:00Start
- 0:22Why Would You Want To Build a Graphql Api with Next
- 2:44Dependencies
- 4:20Graphql Model
- 4:59Resolver
- 7:06Apollo Server
- 12:53Connect to a Database
- 13:26Create a New Database
- 14:28Add Document
- 15:03Install the Faunadb Driver
- 18:38Query the Database
- 19:48Fql Cheat Sheet
- 21:06Lambda Function
- 23:11Deploy Our Application
related talks
22mDo You Even Need That Express Custom Server Any More?
43mGraphQL in the Era of Server Components
59mGoodbye REST; Hello GraphQL
36mEfficient and Performant GraphQL Serverless APIs
34mGraphQL & Apollo in Vue
21mApollo, GraphQL and Vue the ultimate stack
22mNext.js is my main web server for all APIs. And I like it!
23mKiling BFFs with GraphQL and Next.js
