Returning Data from a Database

Learn how to read data from a MongoDB database in GraphQL resolvers.

We’ve managed to get our database up and running and have even populated it with some seed data. Now, it’s time to integrate it with our application.

New file structure

In this lesson, the directory structure of our application will change slightly, and we will add a few more files and directories:

  • model: A directory that will contain all the Mongoose models we’ll use to interact with the data in our database.
  • mongo.js: A command that configures the connection to MongoDB.
  • logger.js: A logger’s configuration.

Here’s how we’ll organize our project:

Get hands-on with 1200+ tech skills courses.