Skip to main content
The Graph CLI is an essential tool enabling developers to seamlessly create, deploy, and manage subgraphs—providing streamlined blockchain data querying and indexing. It gives you superuser access to our enterprise-grade subgraph infrastructure. Additionally, we are fully compatible with The Graph’s tooling, and the CLI works seamlessly out of the box with our platform.

Deployment Network Definitions

For developers who are already familiar with Graph Protocol tooling, below are the network definitions to deploy subgraphs on 0xGraph. These settings can be configured in the subgraph.yaml file:

Installation

1

Install CLI Package

NPM CLI Package

Install the graph npm package

Generate API Key

Create an API key: Visit 0xGraph Dashboard to generate your API key. For a comprehensive tutorial on generating API keys, visit the Account Creation Page.
You need to specify the 0xGraph deployment endpoint. Your API key should only be used for the 0xGraph deployment endpoint.

Create your own Subgraph

Details regarding creating your own Subgraph is beyond the scope of this documentation. The Graph’s official documentation provides detailed guides and examples for each step of the Subgraph creation process. It also covers advanced topics such as indexing strategies, filtering, and pagination. We recommend referring to their documentation for a comprehensive reference on Subgraph development with The Graph.

Core Components

A typical Subgraph project has the following components:

Manifest File

The subgraph.yaml manifest file serves as the root configuration, containing smart contract references, entity mappings, handler functions, and deployment parameters like startBlock and description.

Schema File

The schema.graphql file defines all the entities and their relationships for your Subgraph’s GraphQL API, determining what blockchain data will be indexed and made queryable.

Mappings File

Written in AssemblyScript, a TypeScript-like language specifically designed for WebAssembly, the mappings file transforms raw blockchain data into structured entities that match your GraphQL schema through a set of data handling functions.
Messari maintains a well-curated GitHub repository that offers a comprehensive collection of example Subgraphs, which serves as a valuable resource for those seeking to start their subgraph development journey.

Subgraph Compilation

1

Generate Types and Mappings

The codegen step generates code files for indexing and querying data based on your schema and mappings.
Run in your project root:
Success output:
View all options with graph codegen --help:
2

Build Your Subgraph

After generating types, build your subgraph:
Success Output:
View all options with graph build --help:
3

Deploy your Subgraph

Then deploy your Subgraph:
Success output:

View Your Subgraphs

Access your deployed Subgraphs through the web-based UI at telos.0xgraph.xyz