Recently, I got interested in working with a Next.js React Framework for server-side-rendered (SSR) applications. I’m using Next more and more for my pet projects. I was surprised by how intuitive, easy, and enjoyable working with NextJS is.

In this article, we’re going to set up GraphQL API with a MongoDB connection for a NextJS app. I surprised that both NextJS and Apollo GraphQL examples were lacking such a common use case with MongoDB. There were examples with PostgreSQL but I wanted to use a non-SQL database. After spending some time learning and reading I put together this step-by-step guide on how to connect your Apollo Server GraphQL API to MongoDB and read/write data to Mongo database in your GraphQL resolvers.

#mongodb

Setting up GraphQL API with MongoDB and Apollo Server for a NextJS app
19.05 GEEK