This article will teach you how to build a GraphQL API with Next.js to implement JWT Authentication using apollo-server-micro, TypeGraphQL, MongoDB, Redis, Mongoose, and Typegoose.
- Initialize a Typescript Next.js Project
- Setup MongoDB and Redis Database Servers
- Setting up Environment Variables
- Connect the Redis and MongoDB Servers to Next.js
- Connect to the MongoDB Server
- Connect to the Redis Server
- Start the GraphQL Apollo Server
- Creating TypeGraphQL and Typegoose Schemas
- Creating the Typegoose Schema
- Creating the TypeGraphQL Schemas
- Creating an Error Handler
- Create Utility Functions to Generate and Verify JWTs
- How to Generate the Private and Public Keys
- Create an Authentication Guard
- Creating the Authentication Services
- Service to Register the User
- Service to Sign in the User
- Service to Get the Authenticated User
- Service to Refresh the Access Token
- Service to Logout the User
- Create the TypeGraphQL Resolvers
- Update the GraphQL Server
- Testing the GraphQL API in Postman
Read the entire article here: https://codevoweb.com/graphql-api-next-mongodb-access-and-refresh-tokens
Articles in this series::