Skip to content

Commit 4a39431

Browse files
idalithbbenface
andauthored
Adding gnd guide (#1029)
* adding a page * Lint --------- Co-authored-by: benface <[email protected]>
1 parent ccebeab commit 4a39431

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

website/src/pages/en/subgraphs/developing/creating/_meta.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default {
66
'subgraph-manifest': '',
77
'ql-schema': '',
88
'assemblyscript-mappings': '',
9+
'graph-node-dev': '',
910
advanced: '',
1011
'graph-ts': titles['graph-ts'] ?? '',
1112
'unit-testing-framework': '',
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: Graph Node Dev Mode
3+
---
4+
5+
## Overview
6+
7+
Graph Node Developer Mode (GND) is a developer-friendly Graph Node runner designed for local Subgraph development. It simplifies setup by removing the need for IPFS and offering smart defaults like automatic database handling (on Unix) and live Subgraph redeployment.
8+
9+
## Prerequisites
10+
11+
- PostgreSQL installed and running
12+
- Access to an Ethereum RPC endpoint (e.g., Anvil, Hardhat)
13+
14+
## Step 1. Set Up
15+
16+
Install `gnd` using the Graph CLI:
17+
18+
```
19+
graph node install
20+
```
21+
22+
This installs the latest `gnd` binary to:
23+
24+
- Unix: `~/.local/bin`
25+
- Windows: `%USERPROFILE%\gnd\bin`
26+
27+
Ensure this directory is in your system `PATH`:
28+
29+
```
30+
gnd --version
31+
```
32+
33+
## Step 2. Usage
34+
35+
Run `gnd` inside your Subgraph project directory.
36+
37+
### Minimal Usage (Unix)
38+
39+
```
40+
gnd --ethereum-rpc mainnet:http://localhost:<PORT>
41+
```
42+
43+
### With Hot-Reloading
44+
45+
```
46+
gnd --ethereum-rpc mainnet:http://localhost:<PORT> --watch
47+
```
48+
49+
`--watch` enables automatic Subgraph redeploys when the build directory changes
50+
51+
### Windows (Postgres URL required)
52+
53+
```
54+
gnd --ethereum-rpc mainnet:http://localhost:<PORT> --postgres-url "postgre
55+
sql://graph:yourpassword@localhost:5432/graph-node"
56+
```
57+
58+
## Step 3. PostgreSQL Setup on Windows
59+
60+
After installing PostgreSQL, follow these steps:
61+
62+
### 1. Launch `psql` as SUPERUSER
63+
64+
```
65+
psql -U postgres
66+
```
67+
68+
Replace postgres with your superuser name if different.
69+
70+
### 2. Run the following commands
71+
72+
```
73+
create user graph with password 'yourpassword';
74+
create database "graph-node" with owner=graph template=template0 encodi
75+
ng='UTF8' locale='C';
76+
\c graph-node
77+
create extension pg_trgm;
78+
create extension btree_gist;
79+
create extension postgres_fdw;
80+
grant usage on foreign data wrapper postgres_fdw to graph;
81+
```
82+
83+
Use this URL when running `gnd`:
84+
85+
```
86+
--postgres-url "postgresql://graph:yourpassword@localhost:5432/graph-nod
87+
e"
88+
```
89+
90+
### 3. Flags & Options
91+
92+
| Flag | Description |
93+
| ---------------- | --------------------------------------------------------------------------------------- |
94+
| `--watch` | _(Optional)_ Watches the Subgraph build directory and redeploys on changes. |
95+
| `--manifests` | Path(s) to manifest files. Format: `[BUILD_DIR:]/manifest`. Default: `./subgraph.yaml`. |
96+
| `--sources` | Source manifest aliases for resolving shared data sources. |
97+
| `--database-dir` | Directory to store temporary Postgres instance (**Unix only**). Default: `./build`. |
98+
| `--postgres-url` | URL for PostgreSQL DB. **Required on Windows.** |
99+
| `--ethereum-rpc` | Format: `network[:capabilities]:URL`. **Required.** |
100+
| `--ipfs` | IPFS endpoint(s). Default: `https://api.thegraph.com/ipfs`. |
101+
102+
## Step 4. Running a Subgraph
103+
104+
To run a Subgraph:
105+
106+
### 1. Navigate to your Subgraph directory
107+
108+
```
109+
cd path/to/your-subgraph
110+
```
111+
112+
### 2. Start gnd with an Ethereum RPC
113+
114+
```
115+
gnd --ethereum-rpc mainnet:http://localhost:<PORT>
116+
```
117+
118+
This will build and start the Subgraph.
119+
120+
### 3. Query your Subgraph at
121+
122+
```
123+
http://localhost:8000/subgraphs/name/subgraph-0/
124+
```
125+
126+
## Notes
127+
128+
- On Unix, if `-postgres-url` is not provided, `gnd` automatically starts a temporary Postgres instance in the `-database-dir` folder (default: `./build`).
129+
130+
- On Windows, you must provide a valid `-postgres-url`.
131+
132+
- IPFS is optional; `gnd` uses `https://api.thegraph.com/ipfs` by default.

0 commit comments

Comments
 (0)