13 BUILDING THE GRAPHQL API

In this chapter, you’ll add a GraphQL API to the middleware by defining its schema, as well as resolvers for each query and mutation. These resolvers will complement the Mongoose services created in Chapter 12. The queries will be public; however, we’ll expose our mutations as protected APIs by adding an authorization layer via OAuth.

Unlike in the GraphQL API of Chapter 6, we’ll follow a pattern of modularization to implement these schemas and resolvers. Instead of writing everything in one big file, we’ll split the elements into separate files. Like using modules in modern JavaScript, this approach has the benefit ...

Get The Complete Developer 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.