subgraphs > Developing > Deploying > Deploy Using Subgraph Studio

Deploy Using Subgraph Studio

Reading time: 5 min

Learn how to deploy your subgraph to Subgraph Studio.

Note: When you deploy a subgraph, you push it to Subgraph Studio, where you'll be able to test it. It's important to remember that deploying is not the same as publishing. When you publish a subgraph, you're publishing it on-chain.

Subgraph Studio Overview

链到本节

In Subgraph Studio, you can do the following:

  • View a list of subgraphs you've created
  • Manage, view details, and visualize the status of a specific subgraph
  • 为特定子图创建和管理 API 密钥
  • Restrict your API keys to specific domains and allow only certain Indexers to query with them
  • Create your subgraph
  • Deploy your subgraph using The Graph CLI
  • Test your subgraph in the playground environment
  • Integrate your subgraph in staging using the development query URL
  • Publish your subgraph to The Graph Network
  • Manage your billing

Install The Graph CLI

链到本节

Before deploying, you must install The Graph CLI.

You must have Node.js and a package manager of your choice (npm, yarn or pnpm) installed to use The Graph CLI. Check for the most recent CLI version.

Install with yarn

链到本节
yarn global add @graphprotocol/graph-cli

Install with npm

链到本节
npm install -g @graphprotocol/graph-cli

开始

链到本节
  1. Open Subgraph Studio.
  2. Connect your wallet to sign in.
    • You can do this via MetaMask, Coinbase Wallet, WalletConnect, or Safe.
  3. After you sign in, your unique deploy key will be displayed on your subgraph details page.
    • The deploy key allows you to publish your subgraphs or manage your API keys and billing. It is unique but can be regenerated if you think it has been compromised.

Important: You need an API key to query subgraphs

如何在子图工作室中创建子图

链到本节

For additional written detail, review the Quick Start.

子图与图形网络的兼容性

链到本节

In order to be supported by Indexers on The Graph Network, subgraphs must:

  • Index a supported network
  • 不得使用以下任何功能:
    • ipfs.cat & ipfs.map
    • 非致命错误
    • 嫁接

Initialize Your Subgraph

链到本节

Once your subgraph has been created in Subgraph Studio, you can initialize its code through the CLI using this command:

graph init <SUBGRAPH_SLUG>

You can find the <SUBGRAPH_SLUG> value on your subgraph details page in Subgraph Studio, see image below:

Subgraph Studio - Slug

After running graph init, you will be asked to input the contract address, network, and an ABI that you want to query. This will generate a new folder on your local machine with some basic code to start working on your subgraph. You can then finalize your subgraph to make sure it works as expected.

Graph 认证

链到本节

Before you can deploy your subgraph to Subgraph Studio, you need to log into your account within the CLI. To do this, you will need your deploy key, which you can find under your subgraph details page.

Then, use the following command to authenticate from the CLI:

graph auth <DEPLOY KEY>

Deploying a Subgraph

链到本节

Once you are ready, you can deploy your subgraph to Subgraph Studio.

Deploying a subgraph with the CLI pushes it to the Studio, where you can test it and update the metadata. This action won't publish your subgraph to the decentralized network.

Use the following CLI command to deploy your subgraph:

graph deploy <SUBGRAPH_SLUG>

After running this command, the CLI will ask for a version label.

  • It's strongly recommended to use semver for versioning like 0.0.1. That said, you are free to choose any string as version such as v1, version1, or asdf.
  • The labels you create will be visible in Graph Explorer and can be used by curators to decide if they want to signal on a specific version or not, so choose them wisely.

Testing Your Subgraph

链到本节

After deploying, you can test your subgraph (either in Subgraph Studio or in your own app, with the deployment query URL), deploy another version, update the metadata, and publish to Graph Explorer when you are ready.

Use Subgraph Studio to check the logs on the dashboard and look for any errors with your subgraph.

Publish Your Subgraph

链到本节

In order to publish your subgraph successfully, review publishing a subgraph.

Versioning Your Subgraph with the CLI

链到本节

If you want to update your subgraph, you can do the following:

  • You can deploy a new version to Studio using the CLI (it will only be private at this point).
  • Once you're happy with it, you can publish your new deployment to Graph Explorer.
  • This action will create a new version of your subgraph that Curators can start signaling on and Indexers can index.

You can also update your subgraph's metadata without publishing a new version. You can update your subgraph details in Studio (under the profile picture, name, description, etc.) by checking an option called Update Details in Graph Explorer. If this is checked, an on-chain transaction will be generated that updates subgraph details in Explorer without having to publish a new version with a new deployment.

Note: There are costs associated with publishing a new version of a subgraph to the network. In addition to the transaction fees, you must also fund a part of the curation tax on the auto-migrating signal. You cannot publish a new version of your subgraph if Curators have not signaled on it. For more information, please read more here.

子图版本的自动归档

链到本节

Whenever you deploy a new subgraph version in Subgraph Studio, the previous version will be archived. Archived versions won't be indexed/synced and therefore cannot be queried. You can unarchive an archived version of your subgraph in Subgraph Studio.

Note: Previous versions of non-published subgraphs deployed to Studio will be automatically archived.

Subgraph Studio - Unarchive

编辑

上页
单元测试框架
下页
子图工作室常见问题
编辑