Chapter 6. CRUD Operations

The first time I heard the term “CRUD application,” I wrongfully assumed that it referred to an application that did something dirty or tricky. Admittedly, “CRUD” sounds as if it refers to something that would be scraped off the bottom of a shoe. In fact, the acronym was first popularized in the early 1980s by British technology author James Martin in reference to applications that create, read, update, and delete data. Though the term has been around for well over a quarter of a century, it still applies to many applications developed today. Consider the applications that you interact with daily—to-do lists, spreadsheets, content management systems, text editors, social media websites, and several others—and chances are that many of them fall into the CRUD application format. A user creates some data, accesses or reads data, and may update or delete that data.

Our Notedly application will follow the CRUD pattern. Users will be able to create, read, update, and delete their own notes. In this chapter, we’ll implement the essential CRUD functionality of our API by connecting our resolvers and database.

Separating Our GraphQL Schema and Resolvers

Currently our src/index.js file is home to our Express/Apollo server code as well as our API’s schema and resolvers. As you can imagine, this could get a bit unwieldy as our codebase grows. Before this happens, let’s take some time to do a minor refactor that separates our schema, resolvers, and server code. ...

Get JavaScript Everywhere 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.