This chapter covers:
- Using Node.js drivers for PostgreSQL and MongoDB
- Seeding local databases with test data
- Using the GraphQL schema language to build a schema
- Creating resolver functions to make a schema executable
- Using an interface to communicate with a GraphQL service
- Creating an executable schema object using constructor and type helper objects
- Creating custom object types and handling errors
- Working with asynchronous calls to the database service
In the previous chapter, we designed the database models for AZdev and came up with the initial structure of its GraphQL schema. In this chapter, we’ll use Node.js database drivers and the GraphQL.js implementation to expose the entities in the databases through the use of resolver functions. To make a GraphQL schema executable under a GraphQL API service, you need to implement resolver functions.
Warning
You need a modern version of Node.js installed in your OS to follow along from this point. If you don’t have Node or if you have an old version of it (anything less than 13.2), download the latest from nodejs.org and use that.
Some familiarity with the Node.js runtime is needed. You don’t need to be an expert in Node but if you have never worked with it before you should probably learn its basics before proceeding with this chapter. I wrote a short introductory book on Node which you can get at az.dev/node-intro.