Step-by-step guide to run CouchGraph locally and make your first GraphQL queries.
- Go 1.26+ (or Docker)
- Docker & Docker Compose (for running CouchDB locally)
curl(for testing and seeding)
git clone https://github.com/devton/couchgraph.git
cd couchgraph
# Copy sample environment configuration
cp .env.example .envStart a local CouchDB 3.4 instance with persistent storage:
docker-compose up -d couchdbVerify CouchDB is running:
curl http://localhost:5984/
# Response: {"couchdb":"Welcome","version":"3.4.x",...}Run the included seed script to create sample documents, a Mango index, and a MapReduce view:
./examples/seed-data.shgo run ./cmd/serverThe server will start on port 8080:
{"level":"info","ts":"...","msg":"connected to CouchDB","url":"http://localhost:5984","database":"couchgraph"}
{"level":"info","ts":"...","msg":"GraphQL Playground enabled","url":"http://localhost:8080"}
{"level":"info","ts":"...","msg":"starting CouchGraph server","addr":":8080"}
Open your browser at http://localhost:8080 to interact with the GraphQL Playground.
mutation {
upsertDoc(input: {
data: {
type: "user"
name: "Alice Developer"
email: "alice@couchgraph.dev"
active: true
}
}) {
ok
_id
_rev
}
}Note
CouchGraph automatically generates a UUIDv7 time-ordered ID for your document (e.g., 01927f3a-1001-7000-8000-...).
query {
findDocs(input: {
selector: {
type: "user"
active: true
}
limit: 10
}) {
docs {
_id
_rev
data
}
bookmark
}
}query {
documents(ids: [
"01927f3a-1001-7000-8000-000000000001",
"01927f3a-1002-7000-8000-000000000002"
]) {
_id
data
}
}If you prefer not to install Go locally, you can run both CouchDB and CouchGraph using Docker Compose:
docker-compose up -dTo view logs:
docker-compose logs -f couchgraphTo stop:
docker-compose downEnvironment variables can be provided in .env or passed directly to the container:
| Variable | Type | Default | Description |
|---|---|---|---|
COUCHGRAPH_COUCHDB_URL |
String | http://localhost:5984 |
CouchDB base URL |
COUCHGRAPH_COUCHDB_USER |
String | admin |
CouchDB admin username |
COUCHGRAPH_COUCHDB_PASSWORD |
String | password |
CouchDB admin password |
COUCHGRAPH_COUCHDB_DATABASE |
String | couchgraph |
Optional. Database for single-database mode (auto-created if missing). Workspace projects set their own in couchgraph.yaml |
COUCHGRAPH_SERVER_PORT |
Integer | 8080 |
Port for HTTP server |
COUCHGRAPH_SERVER_PLAYGROUND_ENABLED |
Boolean | true |
Enable GraphQL Playground at / |
COUCHGRAPH_LOG_LEVEL |
String | info |
Logging verbosity (debug, info, warn, error) |
COUCHGRAPH_LOG_FORMAT |
String | console |
Format for logs (console or json) |