When to Use Configuration Files
Use TOML configuration files when you need:- Multiple databases: Sharding across multiple PostgreSQL instances
- Multiple chains: Indexing several blockchain networks
- Read replicas: Distributing query load across replica databases
- Node specialization: Dedicated index nodes and query nodes
- Custom deployment rules: Control where subgraphs are stored and indexed
Configuration File Structure
The TOML configuration file has four main sections:Using a Configuration File
Specify the configuration file with the--config flag:
--config, you cannot use:
--postgres-url--postgres-secondary-hosts--postgres-host-weights--ethereum-rpc(define in config file instead)
Environment Variable Expansion
Configuration files support environment variable expansion:envsubst:
Store Configuration
The[store] section defines PostgreSQL databases for storing subgraph data.
Single Database Setup
Minimal configuration equivalent to--postgres-url:
Multiple Databases (Sharding)
Split subgraph storage across multiple databases:Connection Pool Configuration
number | rules
Number of database connections per Graph Node instanceCan be a fixed number or rules based on node ID:Rules are evaluated in order; first match wins.
number
default:"1"
Query traffic distribution weight
0: Don’t send queries (indexing only)- Higher values: More query traffic
string
required
PostgreSQL libpq connection stringSupports environment variable expansion:
${VAR_NAME}Validating Pool Configuration
Usegraphman to validate connection pool settings:
Chain Configuration
The[chains] section configures blockchain network providers.
Basic Chain Setup
Multi-Chain Configuration
Provider Configuration
string
required
Provider name (appears in logs)
string
required
RPC endpoint URL
array
default:"[]"
Provider capabilities:
archive: Full historical statetraces: Supportsdebug_traceBlockByNumberno_eip1898: Doesn’t support EIP-1898 (block by hash/number object)no_eip2718: Doesn’t returntypefield in transaction receiptscompression/gzip: Supports gzip compressioncompression/brotli: Supports brotli compressioncompression/deflate: Supports deflate compression
object
HTTP headers to include in requests
number
Maximum subgraphs that can use this providerAt least one provider should be unlimited.
string
default:"rpc"
Connection type:
rpc, ws, or ipcProvider Types
string
default:"web3"
Provider implementation:
web3: Standard Ethereum JSON-RPC (default)firehose: StreamingFast Firehoseweb3call: Web3 provider foreth_callonly
Advanced: Provider Limits per Node
Limit which nodes can use specific providers:Deployment Rules
The[deployment] section controls where new subgraphs are deployed.
Deployment Rule Structure
Rules are evaluated in order. First matching rule determines placement.Match Conditions
regex
Regular expression matching subgraph name
string | array
Network name(s) the subgraph indexes
Shard Selection
string
default:"primary"
Fixed shard name for deployment storage
array
List of shards; chooses the one with fewest deployments
Indexer Selection
array
required
List of node IDs eligible to index this deploymentGraph Node chooses the indexer with fewest assigned subgraphs.Names must match the
--node-id argument when starting nodes.Simulating Deployment
Test where a subgraph would be deployed:Query Node Configuration
Designate nodes as query-only (no indexing):- Only respond to GraphQL queries
- Don’t connect to blockchain providers
- Don’t index subgraphs
Complete Example
Starting Nodes with Configuration
Index Nodes
Query Nodes
[general] query regex.
Validation and Testing
Validate Configuration
- Syntax errors
- Undefined shards referenced in deployment rules
- Missing required sections
Check Connection Pools
Simulate Deployment
Best Practices
Connection Pool Sizing
Connection Pool Sizing
Index nodes: 10-30 connections per shardQuery nodes: 50-100 connections per shardMonitor
GRAPH_STORE_CONNECTION_WAIT_TIME to detect pool exhaustion.Read Replica Usage
Read Replica Usage
Set main database weight to This reduces load on the primary database.
0 for shards with replicas:Provider Redundancy
Provider Redundancy
Always configure at least 2 providers per chain for failover:
Deployment Rule Ordering
Deployment Rule Ordering
Place most specific rules first:
Troubleshooting
Configuration validation errors
Configuration validation errors
Run validation to see specific issues:Common issues:
- Undefined shard referenced in deployment rule
- Missing required
[deployment]section - Invalid regex in deployment match
Subgraph deployed to wrong shard
Subgraph deployed to wrong shard
Simulate deployment to check rules:Verify deployment rules are ordered correctly (most specific first).
Connection pool exhaustion
Connection pool exhaustion
Check pool usage:Increase pool size for heavily loaded nodes:
Next Steps
- Environment Variables - Fine-tune behavior beyond config files
- Docker Setup - Run Graph Node with Docker
- Building from Source - Compile and run Graph Node

