2. Updating dependencies

Updating dependencies

In an editor of your choice, open up the project and navigate to the package.json file.

Under the dependencies section, we'll find the three packages that we need to update right away.

"dependencies": {
"apollo-datasource-rest": "^0.11.0",
"apollo-server": "^3.0.0",
"graphql": "^15.5.1"
  • With the upgrade to version 4, the apollo-server package is now identified under @apollo/server.

  • The naming convention has also changed for the apollo-datasource-rest package; we'll update it to @apollo/datasource-rest.

  • We'll also remove the older version of graphql and update it to the version required by @apollo/server.

  • Aside from those updates, we have one new package to add — graphql-tag — which we'll see come into play when we update our server's code.

Let's make those changes now.

  1. Clear out the dependencies in your package.json file so you're left with an empty dependencies object. Save package.json.

    "dependencies": {
  2. Because we've already installed the old packages to see our AS3 server in action, let's clear out our node_modules and package-lock.json file. Stop the server running in the terminal, and run the following command.

    rm -rf node_modules package-lock.json
  3. Next, run the following command to install our new dependencies.

    npm install @apollo/server @apollo/datasource-rest graphql graphql-tag

Great! Our new dependencies are installed — but we're not yet ready to run our server. In the next section, we'll update our server code to use these new packages.


Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.