WunderGraph Cosmo CLI
raw JSON →The `wgc` package is the official command-line interface (CLI) for WunderGraph Cosmo, an open-source, full-lifecycle GraphQL API management platform. It empowers developers to manage federated GraphQL APIs and subgraphs, perform critical schema checks and composition validations, generate and deploy router configurations, and integrate these processes seamlessly into CI/CD pipelines. As of its current stable version `0.114.2`, the project exhibits a highly active release cadence across its components, including the router and control plane, indicating continuous development. Key differentiators include its comprehensive support for GraphQL Federation v1 and v2, a centralized Schema Registry with versioning, automated composition checks for breaking changes, integrated observability with OpenTelemetry and Prometheus, and robust access control mechanisms like OIDC, RBAC, and SCIM.
Common errors
error command not found: wgc ↓
wgc globally using npm install -g wgc@latest or run commands via npx -y wgc@latest <command>. error Error: Node.js v18.17.0 is not supported. Please use Node.js v20 LTS or higher. ↓
nvm (Node Version Manager) to easily manage and switch Node.js versions (e.g., nvm install 20 && nvm use 20). error Error: ENOENT: no such file or directory, open 'graph.localhost.yaml' ↓
Warnings
gotcha The `wgc` CLI tool requires Node.js v20 LTS or higher to function correctly. Using older versions may lead to installation errors or unexpected runtime behavior. ↓
gotcha The quickstart guide and common deployment patterns for the Cosmo router heavily rely on Docker. Users without Docker installed and properly configured will be unable to run the router locally as described. ↓
gotcha Installing `wgc` locally using `npm install wgc` (without the `-g` flag) will not add the `wgc` command to your system's PATH. This means direct `wgc` command invocation will fail with a 'command not found' error. ↓
Install
npm install wgc yarn add wgc pnpm add wgc Imports
- wgc (global install) wrong
npm install wgccorrectnpm install -g wgc@latest - wgc (npx execution) wrong
node wgccorrectnpx -y wgc@latest <command> - wgc (command invocation) wrong
wgc:router:composecorrectwgc router compose --input graph.localhost.yaml --out config.json
Quickstart
git clone https://github.com/wundergraph/cosmo-demo.git
cd cosmo-demo
npm install -g wgc@latest
chmod +x start-subgraphs.sh
./start-subgraphs.sh &
cd router
wgc router compose --input graph.localhost.yaml --out config.json
docker run \
--name cosmo-router \
--rm \
-p 3002:3002 \
--add-host=host.docker.internal:host-gateway \
--platform=linux/amd64 \
-e pull=always \
-e DEV_MODE=true \
-e LISTEN_ADDR=0.0.0.0:3002 \
-e EXECUTION_CONFIG_FILE_PATH="/config/config.json" \
-v "$(pwd)/config.json:/config/config.json" \
ghcr.io/wundergraph/cosmo/router:latest
# Access the federated GraphQL API at http://localhost:3002