5 минуты
Deploying Using Subgraph Studio
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 onchain.
Обзор Subgraph Studio
В Subgraph Studio Вы можете выполнять следующие действия:
- View a list of Subgraphs you’ve created
- Manage, view details, and visualize the status of a specific Subgraph
- Create and manage your API keys for specific Subgraphs
- Ограничивать использование своих API-ключей определенными доменами и разрешать только определенным индексаторам выполнять запросы с их помощью
- 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
- Управлять своими платежами
Установка The Graph CLI
Перед развертыванием необходимо установить The Graph CLI.
Для использования The Graph CLI у Вас должны быть установлены Node.js и менеджер пакетов на Ваш выбор (npm
, yarn
или pnpm
). Проверьте у себя наличие самой последней версии CLI.
Установка с помощью yarn
1yarn global add @graphprotocol/graph-cli
Установка с помощью npm
1npm install -g @graphprotocol/graph-cli
Начнем
- Откройте Subgraph Studio.
- Подключите свой кошелек для входа.
- Вы можете это сделать через MetaMask, Coinbase Wallet, WalletConnect или Safe.
- 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
How to Create a Subgraph in Subgraph Studio
For additional written detail, review the Quick Start.
Совместимость подграфов с сетью Graph
To be supported by Indexers on The Graph Network, Subgraphs must index a supported network. For a full list of supported and unsupported features, check out the Feature Support Matrix repo.
Инициализация Вашего Субграфа
Once your Subgraph has been created in Subgraph Studio, you can initialize its code through the CLI using this command:
1graph init <SUBGRAPH_SLUG>
You can find the <SUBGRAPH_SLUG>
value on your Subgraph details page in Subgraph Studio, see image below:

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.
После этого используйте следующую команду для аутентификации через CLI:
1graph auth <DEPLOY KEY>
Развертывание субграфа
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:
1graph deploy <SUBGRAPH_SLUG>
После выполнения этой команды CLI запросит метку версии.
- Настоятельно рекомендуется использовать semver для управления версиями типа
0.0.1
. При этом Вы можете выбрать любую строку в качестве версии, например:v1
,version1
илиasdf
. - Созданные вами метки будут видны в Graph Explorer, и кураторы смогут использовать их для принятия решения, сигнализировать на определенную версию или нет, поэтому выбирайте метки с умом.
Тестирование Вашего субграфа
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.
Публикация Вашего субграфа
In order to publish your Subgraph successfully, review publishing a Subgraph.
Управление версиями Вашего субграфа с помощью CLI
If you want to update your Subgraph, you can do the following:
- Вы можете развернуть новую версию в Studio, используя CLI (на этом этапе она будет только приватной).
- Если результат Вас устроит, Вы можете опубликовать новое развертывание в 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 onchain 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.
