Skip to main content
This guide covers the complete workflow for deploying subgraphs to a Graph Node instance, from development to production.

Prerequisites

Before deploying a subgraph, ensure you have:
  1. A running Graph Node instance
  2. PostgreSQL database configured and accessible
  3. IPFS node running and accessible
  4. An Ethereum node or provider endpoint
  5. Graph CLI or GND installed

Installation

Setting Up Graph Node

Using Docker Compose

The quickest way to get started is using Docker Compose:
This starts:
  • Graph Node on http://localhost:8000 (GraphQL HTTP)
  • IPFS on http://localhost:5001
  • PostgreSQL on localhost:5432
  • Admin API on http://localhost:8020

Running from Source

Using Existing Services

If you already have IPFS and PostgreSQL running:

Creating a Subgraph

Initialize Project

This creates a project structure:

Define Schema

Edit schema.graphql to define your data model:

Configure Manifest

Edit subgraph.yaml to configure your data sources:

Write Mappings

Implement event handlers in src/mapping.ts:

Building the Subgraph

Generate types and compile the subgraph:
command
Generates AssemblyScript types from the GraphQL schema and contract ABIs.
command
Compiles the subgraph to WebAssembly and prepares it for deployment.

Deploying the Subgraph

Create Subgraph

First, create the subgraph on your Graph Node:

Deploy

Deploy your subgraph to the Graph Node:
The deployment process:
  1. Uploads files to IPFS
  2. Creates deployment with unique ID
  3. Starts indexing from startBlock
  4. Makes subgraph available for querying

Querying the Subgraph

Once deployed, you can query your subgraph:
Navigate to http://localhost:8000/subgraphs/name/myorg/my-subgraph to access the GraphQL playground.

Managing Deployments

Check Status

Remove Subgraph

Reassign Subgraph

Move a subgraph to a different node:

Environment Variables

Key environment variables for deployment:
String
default:"info"
Control log levels. Options: error, warn, info, debug, trace
Number
default:"250"
Maximum expected reorg size. Larger reorgs may cause inconsistent data.
Number
default:"500"
How often to poll Ethereum for new blocks (in milliseconds).
Number
default:"100"
The ideal amount of triggers to be processed in a batch.
Number
default:"60"
Timeout for IPFS requests in seconds.
Number
Maximum execution time for a GraphQL query in seconds. Default is unlimited.
Boolean
default:"false"
If set, the process will be killed if unresponsive.

Troubleshooting

Problem: Graph Node can’t connect to EthereumSolutions:
  • Verify RPC endpoint is accessible
  • Check network name matches (e.g., mainnet not ethereum)
  • Ensure provider has required capabilities (archive, traces)
  • Test connection: curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' YOUR_RPC_URL

Best Practices

  1. Test locally first - Always test with a local Graph Node before deploying to production
  2. Use version labels - Tag deployments with semantic versions for tracking
  3. Start small - Begin with a limited block range, then expand
  4. Monitor resources - Watch CPU, memory, and disk usage during indexing
  5. Handle errors gracefully - Use try-catch in mappings and check for null values

Next Steps