-
Notifications
You must be signed in to change notification settings - Fork 6
Config Command
The config command manages the Graphman home directory and configuration. It can display the current configuration or initialize a new home directory with default configuration and extension files.
graphman config [--init-home <home-directory>]
[--options.<name> <value>,...]| Parameter | Description | Default |
|---|---|---|
--init-home |
Initialize a new Graphman home directory | None (display mode) |
--options.encodeSecrets |
Encode secrets in configuration file | false |
When run without parameters:
- Displays the current home directory path
- Shows the contents of
graphman.configurationfile - Warns if home directory or configuration is not set
When --init-home is specified:
- Creates the specified home directory structure
- Copies extension modules
- Creates default configuration file
- Optionally encodes secrets (passwords, passphrases)
- Provides instructions for setting
GRAPHMAN_HOMEenvironment variable
A Graphman home directory contains:
<home-directory>/
├── graphman.configuration # Main configuration file
├── modules/ # Extension modules
│ ├── graphman-extension-pre-request.js
│ ├── graphman-extension-post-export.js
│ ├── graphman-extension-pre-import.js
│ ├── graphman-extension-multiline-text-diff.js
│ └── graphman-extension-policy-code-validator.js
└── queries/ # Custom queries (optional)
└── <schema-version>/
├── custom-query.json
└── custom-query.gql
View current configuration:
graphman configSample Output:
info: home /path/to/graphman/home
info: configuration
{
"gateways": {
"default": {
"address": "https://gateway.example.com:8443",
"username": "admin",
"password": "encoded:abc123...",
"rejectUnauthorized": true,
"allowMutations": false
}
},
"options": {
"log": "info"
}
}
Create a new Graphman home:
graphman config --init-home /path/to/my-graphman-homeOutput:
info: initializing home /path/to/my-graphman-home
info: creating extension module graphman-extension-pre-request.js
info: creating extension module graphman-extension-post-export.js
info: creating extension module graphman-extension-pre-import.js
info: creating extension module graphman-extension-multiline-text-diff.js
info: creating extension module graphman-extension-policy-code-validator.js
info: creating default configuration
info: make sure defining the environment variable, GRAPHMAN_HOME=/path/to/my-graphman-home
Initialize and encode secrets:
graphman config --init-home /path/to/my-graphman-home --options.encodeSecrets trueThis will:
- Create the home directory
- Create default configuration
- Encode any passwords and passphrases in the configuration
{
"gateways": {
"default": {
"address": "https://localhost:8443",
"username": "admin",
"password": "password",
"rejectUnauthorized": true,
"allowMutations": false
}
},
"options": {
"log": "info",
"schema": "v11.2.0"
}
}Each gateway profile contains:
| Field | Description | Required |
|---|---|---|
address |
Gateway URL (https://host:port) | Yes |
username |
Admin username | Yes |
password |
Admin password (can be encoded) | Yes |
rejectUnauthorized |
Validate SSL certificates | No (default: true) |
allowMutations |
Allow import operations | No (default: false) |
passphrase |
Key passphrase (if needed) | No |
keyPath |
Path to client key | No |
certPath |
Path to client certificate | No |
| Option | Description | Default |
|---|---|---|
log |
Log level (error, warn, info, fine) | info |
schema |
Default schema version | Latest version |
extensions |
Custom extension paths | None |
Set up Graphman for first use:
# Initialize home directory
graphman config --init-home ~/graphman-home
# Set environment variable
export GRAPHMAN_HOME=~/graphman-home
# Edit configuration
vim ~/graphman-home/graphman.configuration
# Verify setup
graphman configCreate separate configurations for different environments:
# Development environment
graphman config --init-home ~/graphman-dev
export GRAPHMAN_HOME=~/graphman-dev
# Edit config for dev gateways
# Production environment
graphman config --init-home ~/graphman-prod
export GRAPHMAN_HOME=~/graphman-prod
# Edit config for prod gatewaysInitialize home directory for team members:
# Create shared home directory
graphman config --init-home /shared/graphman-home
# Team members set environment variable
export GRAPHMAN_HOME=/shared/graphman-homeReview current configuration:
graphman configEncode secrets in existing configuration:
# Re-initialize with encoding
graphman config --init-home ~/graphman-home --options.encodeSecrets trueVerify Graphman setup:
# Check configuration
graphman config
# Check version
graphman version
# Test gateway connectivity
graphman export --gateway default --using all:summary --output test.jsonThe GRAPHMAN_HOME environment variable tells Graphman where to find its configuration:
Linux/Mac:
# Temporary (current session)
export GRAPHMAN_HOME=/path/to/graphman-home
# Permanent (add to ~/.bashrc or ~/.zshrc)
echo 'export GRAPHMAN_HOME=/path/to/graphman-home' >> ~/.bashrc
source ~/.bashrcWindows (PowerShell):
# Temporary (current session)
$env:GRAPHMAN_HOME = "C:\path\to\graphman-home"
# Permanent (system-wide)
[System.Environment]::SetEnvironmentVariable('GRAPHMAN_HOME', 'C:\path\to\graphman-home', 'User')Windows (Command Prompt):
# Temporary (current session)
set GRAPHMAN_HOME=C:\path\to\graphman-home
# Permanent (system-wide)
setx GRAPHMAN_HOME "C:\path\to\graphman-home"Graphman can encode passwords for security:
Encoded Format:
{
"password": "encoded:base64encodedvalue"
}Plain Text Format:
{
"password": "mypassword"
}When --options.encodeSecrets true is used:
- Reads existing configuration
- Identifies password and passphrase fields
- Decodes if already encoded (to re-encode)
- Encodes using base64
- Prefixes with
encoded: - Writes back to configuration file
To manually encode a password:
echo -n "mypassword" | base64
# Output: bXlwYXNzd29yZA==
# Use in configuration:
"password": "encoded:bXlwYXNzd29yZA=="The following extensions are copied during initialization:
| Extension | Purpose |
|---|---|
pre-request |
Modify requests before sending to Gateway |
post-export |
Process exported data before saving |
pre-import |
Process data before importing to Gateway |
multiline-text-diff |
Enhanced diff for multiline text |
policy-code-validator |
Validate policy code structure |
Add custom extensions by:
- Creating extension files in
modules/directory - Following the extension naming pattern:
graphman-extension-<name>.js - Configuring in
graphman.configuration:
{
"options": {
"extensions": ["/path/to/custom-extension.js"]
}
}- Installation Directory: Cannot initialize in Graphman installation directory
- Existing Files: Initialization doesn't overwrite existing files
-
Environment Variable: Must set
GRAPHMAN_HOMEafter initialization - Configuration Format: Must be valid JSON
- Secret Encoding: Optional but recommended for security
- Multiple Homes: Can have multiple home directories for different purposes
- Version Control: Consider version controlling configuration (without secrets)
- Use Separate Homes for different environments
- Encode Secrets in production configurations
- Set allowMutations carefully (false for production)
- Use rejectUnauthorized: true in production
- Document Gateway Profiles in team documentation
- Version Control configuration templates (without secrets)
- Backup Configuration before making changes
- Use Descriptive Names for gateway profiles
- version: View Graphman version and home directory
- export: Use configured gateway profiles
- import: Use configured gateway profiles
warn: home directory is not configured
warn: did you forget to configure the GRAPHMAN_HOME environment variable?
Solution:
export GRAPHMAN_HOME=/path/to/graphman-homewarn: configuration is missing, /path/to/graphman-home/graphman.configuration
Solution:
graphman config --init-home /path/to/graphman-homeerror: installation directory is not modifiable
Solution: Use a different directory outside the Graphman installation.
If configuration is invalid JSON:
# Validate JSON
python -m json.tool ~/graphman-home/graphman.configuration#!/bin/bash
# Complete Graphman setup
# Step 1: Initialize home directory
graphman config --init-home ~/graphman-home
# Step 2: Set environment variable
export GRAPHMAN_HOME=~/graphman-home
echo 'export GRAPHMAN_HOME=~/graphman-home' >> ~/.bashrc
# Step 3: Edit configuration
cat > ~/graphman-home/graphman.configuration << 'EOF'
{
"gateways": {
"dev": {
"address": "https://dev-gateway:8443",
"username": "admin",
"password": "encoded:ZGV2cGFzc3dvcmQ=",
"rejectUnauthorized": false,
"allowMutations": true
},
"prod": {
"address": "https://prod-gateway:8443",
"username": "admin",
"password": "encoded:cHJvZHBhc3N3b3Jk",
"rejectUnauthorized": true,
"allowMutations": true
}
},
"options": {
"log": "info",
"schema": "v11.2.0"
}
}
EOF
# Step 4: Verify setup
graphman config
graphman version
# Step 5: Test connectivity
graphman export --gateway dev --using all:summary --output test.json
echo "Setup complete!"#!/bin/bash
# Set up multiple environments
# Development
graphman config --init-home ~/graphman-dev
# ... configure for dev ...
# Staging
graphman config --init-home ~/graphman-staging
# ... configure for staging ...
# Production
graphman config --init-home ~/graphman-prod
# ... configure for prod ...
# Create helper scripts
cat > ~/use-dev.sh << 'EOF'
#!/bin/bash
export GRAPHMAN_HOME=~/graphman-dev
echo "Using development environment"
EOF
cat > ~/use-prod.sh << 'EOF'
#!/bin/bash
export GRAPHMAN_HOME=~/graphman-prod
echo "Using production environment"
EOF
chmod +x ~/use-dev.sh ~/use-prod.sh