How to Add Apollo Server for a GraphQL API in a Node.js App
In this lesson, we'll install the Express variation of the popular Apollo Server library and the GraphQL JavaScript library.
Get the project source code below, and follow along with the lesson material.
Download Project Source CodeTo set up the project on your local machine, please follow the directions provided in the README.md
file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.
This lesson preview is part of the TinyHouse: A Fullstack React Masterclass with TypeScript and GraphQL course and can be unlocked immediately with a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to TinyHouse: A Fullstack React Masterclass with TypeScript and GraphQL with a single-time purchase.

[00:00 - 00:13] We've mentioned before, GraphQL isn't tied to any specific technology since it 's simply a specification. And we've also talked about one of the popular suite of tools in the GraphQL ecosystem, Apollo.
[00:14 - 00:38] Apollo Server, just to reiterate, is one of the libraries within the Apollo toolkit and its responsibilities to help build a GraphQL API. Apollo Server enables us to connect a GraphQL schema to a server and can be used to either spin up a standalone server, be an add-on to an existing node server, or even work within serverless environments.
[00:39 - 00:51] We'll go with the approach of adding Apollo Server to our existing node express server. So to add Apollo Server, we'll first need to install the Apollo Server Express library.
[00:52 - 01:13] We'll head over to our terminal, and then we'll install as an application dependency the Apollo Server Express package. Apollo Server Express is a TypeScript project, so you won't have to install an additional type declaration file for it.
[01:14 - 01:27] To use Apollo Server, however, we'll need to install a northern dependency into our app. We'll need to install the GraphQL JavaScript library because the GraphQL library is a pure dependency of the Apollo Server package.
[01:28 - 01:45] In addition, the GraphQL library will also be used to help build our schema with which we're going to see in the next lesson. We'll install GraphQL as our application's dependency.
[01:46 - 02:04] The GraphQL JavaScript library doesn't have its own type definitions, so we'll need to install the corresponding type declaration file to our application's dev dependencies. This is the only additional libraries we'll need to begin developing our Graph QL schema.