Chapter 3: Connecting to the Database

Our backend and frontend can communicate, create new posts, and respond with a list of all posts while using fake data. The next step on our list will be to use a database, such as a SQL server, to serve as data storage.

We want our backend to persist data to our SQL database by using Sequelize. Our Apollo Server should use this data for queries and mutations, as needed. For this to happen, we must implement database models for our GraphQL entities.

This chapter will cover the following topics:

  • Using databases in GraphQL
  • Using Sequelize in Node.js
  • Writing database models
  • Seeding data with Sequelize
  • Using Apollo with Sequelize
  • Performing database migrations with Sequelize

Technical requirements

The source ...

Get Full-Stack Web Development with GraphQL and React - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.