Getting started for the Hosted Service

Deploying a Subgraph to the Hosted Service.

After having deployed a subgraph locally, we will focus in the following on deploying a subgraph to The Graph’s Hosted Service. As a prerequisite, you will need an account on The Graph’s Explorer. From here, subgraphs can be created through the UI. The subgraphs created on the explorer can be deployed through your terminal.

Ethereum testnets are supported by The Graph Node aside from The Graph’s mainnet.

The second prerequisite is to add a new subgraph in your dashboard. You can do this by visiting /explorer/dashboard on The Graph’s Explorer and clicking on Add Subgraph. Save the new subgraph and you’re ready to go.

Before we start, let’s have a quick look at the steps covered in this guide:

  • 1. Installing Graph CLI
  • 2. Setting up an example subgraph
  • 3. Authenticating with the Hosted Service
  • 4. Using the subgraph in a dApp

1. Installing Graph CLI.

To install Graph CLI globally on your machine, use the following commands by using Yarn or NPM (depending on which package manager you are using):

Copy to Clipboard
Copy to Clipboard

2. Setting up an example subgraph.

After installing Graph CLI, you can either set up your own subgraph or use an example subgraph from The Graph:

Copy to Clipboard
  • <GITHUB_USERNAME> is required. Use your GitHub username
  • <SUBGRAPH_NAME> is required. Use the name of your subgraph project

  • <DIRECTORY> is optional. It’s the name of the directory that your subgraph is created in. Defaults to <SUBGRAPH_NAME>.

3. Authenticating with the Hosted Service.

When running the $ graph init command from above, the CLI will guide you through authenticating with the Hosted Service. It will also help you to prepare and deploy the subgraph. Follow the steps to authenticate and deploy.

Please note: Make sure you are the admin of your organization to receive an access token.

If your deployment was successful, your subgraph will start indexing. You can watch your subgraph and interact with it through the GraphQL playground in the Explorer:

Copy to Clipboard

4. Using the subgraph in a dApp.

You can now use your own or the example subgraph in a dApp built with React. To do so, open a terminal and select a sample dApp compatible with your subgraph and clone it:

Copy to Clipboard

Enter and configure the app directory so that it uses the GraphQL endpoint of your subgraph:

Copy to Clipboard

All you need to do now is to install the dependencies of the dApp and start it:

Copy to Clipboard


Great job! After having deployed an example subgraph locally you’re now able to deploy subgraphs via the Hosted Service.

Go Back

Developer Knowledge Hub

Up next