Observed since 21 Oct, 09:19 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Tookit for interacting with dubhe graphql server
The Dubhe GraphQL Server is an intelligent universal server adapter that automatically connects to databases created by dubhe-indexer and dynamically generates complete GraphQL APIs. Built on PostGraphile, it provides advanced filtering, real-time subscriptions, and comprehensive data access capabilities with zero configuration required.
Install the package in your project:
pnpm install @0xobelisk/graphql-server
Or install globally for CLI usage:
npm install -g @0xobelisk/graphql-server
The server provides a comprehensive CLI interface for configuration:
# Start with default configuration
dubhe-graphql-server start
# Start with custom configuration
dubhe-graphql-server start --port 4000 --database-url postgres://user:pass@localhost:5432/db
# Development mode with debug logging
dubhe-graphql-server start --debug --enable-metrics
# Production mode
dubhe-graphql-server start --env production --no-cors
All configuration can be managed through CLI arguments or environment variables:
| Option | Environment Variable | Default | Description |
|---|---|---|---|
--port, -p | PORT | 4000 | Server port |
--database-url, -d | DATABASE_URL | postgres://postgres:postgres@127.0.0.1:5432/postgres | Database connection URL |
--schema, -s | PG_SCHEMA | public | PostgreSQL schema name |
--endpoint, -e | GRAPHQL_ENDPOINT | /graphql | GraphQL endpoint path |
--cors | ENABLE_CORS | true | Enable CORS |
--subscriptions | ENABLE_SUBSCRIPTIONS | true | Enable GraphQL subscriptions |
--env | NODE_ENV | development | Environment mode |
--debug | DEBUG | false | Enable debug mode (verbose logging) |
--query-timeout | QUERY_TIMEOUT | 30000 | GraphQL query timeout (ms) |
--max-connections | MAX_CONNECTIONS | 1000 | Maximum database connections |
--heartbeat-interval | HEARTBEAT_INTERVAL | 30000 | WebSocket heartbeat interval (ms) |
--enable-metrics | ENABLE_METRICS | false | Enable performance metrics |
--enable-live-queries | ENABLE_LIVE_QUERIES | true | Enable GraphQL live queries |
--enable-pg-subscriptions | ENABLE_PG_SUBSCRIPTIONS | true | Enable PostgreSQL subscriptions |
--enable-native-websocket | ENABLE_NATIVE_WEBSOCKET | true | Enable native WebSocket support |
--realtime-port | REALTIME_PORT | undefined | Realtime WebSocket port |
You can also use a .env file instead of CLI arguments:
# Database configuration (connect to dubhe-indexer database)
DATABASE_URL=postgres://username:password@localhost:5432/sui_indexer_db
# Server configuration
PORT=4000
NODE_ENV=development
# GraphQL configuration
GRAPHQL_ENDPOINT=/graphql
PG_SCHEMA=public
# Feature toggles
ENABLE_CORS=true
ENABLE_SUBSCRIPTIONS=true
# Performance settings
QUERY_TIMEOUT=30000
MAX_CONNECTIONS=1000
HEARTBEAT_INTERVAL=30000
# Debug and monitoring
DEBUG=false
ENABLE_METRICS=false
# Subscription capabilities
ENABLE_LIVE_QUERIES=true
ENABLE_PG_SUBSCRIPTIONS=true
ENABLE_NATIVE_WEBSOCKET=true
REALTIME_PORT=4001
The server automatically scans and adapts to your database structure:
dubhe-indexerThe server uses a modular plugin architecture:
The server provides comprehensive filtering capabilities through the postgraphile-plugin-connection-filter plugin:
# Basic filtering
query GetHighValueAccounts {
accounts(filter: { balance: { gt: "1000" } }) {
nodes {
assetId
account
balance
}
}
}
# Complex logical combinations
query GetComplexFilteredAccounts {
accounts(
filter: {
and: [
{ or: [{ balance: { gt: "1000" } }, { assetId: { like: "%special%" } }] }
{ not: { account: { includesInsensitive: "test" } } }
]
}
) {
nodes {
assetId
account
balance
}
}
}
Advanced WebSocket support powered by PostgreSQL LISTEN/NOTIFY:
# Subscribe to specific table changes
subscription OnAccountChanges {
accounts(first: 10, orderBy: [CREATED_AT_TIMESTAMP_DESC]) {
nodes {
assetId
account
balance
}
}
}
After starting the server, you can access:
http://localhost:4000/ - Server information and table overviewhttp://localhost:4000/playground - Modern GraphQL IDEhttp://localhost:4000/graphql - API endpointhttp://localhost:4000/health - Server health statushttp://localhost:4000/subscription-config - Client configurationws://localhost:4000/graphql - Subscription endpoint# Start development server
pnpm install
dubhe-graphql-server start --debug --enable-metrics
# Build the project
pnpm install
pnpm build
# Start production server
dubhe-graphql-server start \
--env production \
--max-connections 500 \
--query-timeout 60000
Create a docker-compose.yml:
version: '3.8'
services:
graphql-server:
image: node:22-alpine
working_dir: /app
command: npx @0xobelisk/graphql-server start
ports:
- '4000:4000'
environment:
- DATABASE_URL=postgres://user:password@postgres:5432/sui_indexer
- PORT=4000
- ENABLE_SUBSCRIPTIONS=true
- NODE_ENV=production
depends_on:
- postgres
postgres:
image: postgres:15
environment:
- POSTGRES_DB=sui_indexer
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
# CLI approach for production
dubhe-graphql-server start \
--env production \
--database-url "postgres://user:password@prod-db:5432/sui_indexer" \
--port 4000 \
--no-cors \
--max-connections 500 \
--query-timeout 60000 \
--enable-metrics
The server uses a comprehensive configuration interface:
interface ServerConfig {
// Basic server configuration
port: string;
databaseUrl: string;
schema: string;
endpoint: string;
cors: boolean;
subscriptions: boolean;
env: string;
// Debug configuration
debug: boolean;
// Performance configuration
queryTimeout: number;
maxConnections: number;
heartbeatInterval: number;
enableMetrics: boolean;
// Subscription capabilities
enableLiveQueries: boolean;
enablePgSubscriptions: boolean;
enableNativeWebSocket: boolean;
realtimePort?: number;
// Internal debug flags
debugNotifications: boolean;
}
Set up proper database permissions:
-- Create read-only user
CREATE USER graphql_readonly WITH PASSWORD 'secure_password';
-- Grant query permissions
GRANT CONNECT ON DATABASE sui_indexer TO graphql_readonly;
GRANT USAGE ON SCHEMA public TO graphql_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO graphql_readonly;
-- If write permissions needed
GRANT INSERT, UPDATE, DELETE ON specific_tables TO graphql_readonly;
The server provides comprehensive monitoring endpoints:
http://localhost:4000/ - Welcome page with system informationhttp://localhost:4000/health - Health check endpoint with subscription statushttp://localhost:4000/subscription-config - Client configuration for subscriptionshttp://localhost:4000/subscription-docs - Configuration documentationhttp://localhost:4000/playground - Enhanced GraphQL PlaygroundEnable debug mode for detailed logging:
# Enable debug mode with verbose logging
dubhe-graphql-server start --debug
# Enable performance metrics
dubhe-graphql-server start --enable-metrics
# Combine both for comprehensive monitoring
dubhe-graphql-server start --debug --enable-metrics
The server includes built-in performance monitoring:
--debug)Database Connection Failed
Solution: Check DATABASE_URL and database service status
Table Scan Empty
Solution: Ensure dubhe-indexer is running and has created tables
Schema Generation Failed
Solution: Check if table_fields table exists and has data
WebSocket Connection Failed
Solution: Check firewall settings and ENABLE_SUBSCRIPTIONS configuration
# View generated schema
ls -la *.graphql
# Check database connection
psql $DATABASE_URL -c "SELECT version();"
# Test GraphQL endpoint
curl -X POST http://localhost:4000/graphql \
-H "Content-Type: application/json" \
-d '{"query": "{ __schema { types { name } } }"}'
dubhe-indexer database
↓
[Database Introspector] ← Scans table structures
↓
[PostGraphile] ← Generates GraphQL schema
↓
[Enhanced Server Manager] ← Manages HTTP/WebSocket
↓
[GraphQL API + WebSocket] ← Unified endpoint
Database Introspector:
store_* tables and system tablestable_fieldsPostGraphile Engine:
Subscription Manager:
Enhanced Server Manager:
System Tables: Auto-detected indexer tables
table_fields - Table structure metadata (stores field definitions for dynamic tables)Dynamic Tables: Contract-defined tables
store_* - Tables created from your dubhe.config.json (e.g., store_component0, store_component1)created_at_timestamp_ms, updated_at_timestamp_ms, is_deleted--debug --enable-metrics--max-connections appropriately--query-timeout based on usage--no-cors or configure specific origins--enable-metrics for production monitoringDownload counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 2.0.0Registry latest | 29 Jun 2026 | 32 | |
| 1.2.0-pre.125 | 22 Jun 2026 | 32 | |
| 1.2.0-pre.124 | 19 May 2026 | 32 | |
| 1.2.0-pre.123 | 18 May 2026 | 32 | |
| 1.2.0-pre.122 | 13 May 2026 | 32 | |
| 1.2.0-pre.121 | 12 May 2026 | 32 | |
| 1.2.0-pre.120 | 12 May 2026 | 32 | |
| 1.2.0-pre.119 | 11 May 2026 | 32 | |
| 1.2.0-pre.118 | 8 Apr 2026 | 32 | |
| 1.2.0-pre.117 | 7 Apr 2026 | 32 | |
| 1.2.0-pre.115 | 29 Mar 2026 | 32 | |
| 1.2.0-pre.113 | 19 Mar 2026 | 32 | |
| 1.2.0-pre.112 | 18 Mar 2026 | 32 | |
| 1.2.0-pre.110 | 8 Mar 2026 | 32 | |
| 1.2.0-pre.109 | 8 Mar 2026 | 32 | |
| 1.2.0-pre.108 | 7 Mar 2026 | 32 | |
| 1.2.0-pre.107 | 7 Mar 2026 | 32 | |
| 1.2.0-pre.106 | 7 Mar 2026 | 32 | |
| 1.2.0-pre.105 | 6 Mar 2026 | 32 | |
| 1.2.0-pre.104 | 6 Mar 2026 | 32 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 09:19 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:3e5ddba0419fe2f2462202bf42d8778f5c88c29ec3b69b086b0e33a36ee25f09