How to Install Apollo Server for GraphQL

In this lesson, we'll install the Express variation of the popular Apollo Server library and the GraphQL JavaScript library.

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To 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.

Installing Apollo Server and GraphQL

📣 The graphql JavaScript library now provides its own type definitions so we'll no longer need to install the accompanying community prepared typings.

We've mentioned that the GraphQL specification isn't tied to any specific technology. We've also talked about one of the popular suite of tools in the GraphQL ecosystem, Apollo.

Apollo Server is one of the libraries within the Apollo framework and its responsibility is to help build a GraphQL API within Node applications. Apollo Server enables us to connect a GraphQL schema to a server and can be used to spin up a stand-alone server, be an add-on to an existing Node server, or even work within "serverless" environments. We'll go with the approach of adding Apollo Server to our existing Node/Express server.

This lesson preview is part of the The newline Guide to Building Your First GraphQL Server with Node and TypeScript course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to The newline Guide to Building Your First GraphQL Server with Node and TypeScript, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course The newline Guide to Building Your First GraphQL Server with Node and TypeScript
  • [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.