Configure Router - WunderGraph

Prerequisites

Ensure you have the following files generated from the Define Contracts step:

1. Update Router Configuration

You need to modify your router’s config.yaml to enable the ConnectRPC server and tell it where to find your service definitions. The router uses a storage provider to specify the root services directory. The router recursively walks this directory to discover all .proto files and their associated .graphql operations. Add the following configuration blocks:

# Storage providers must be defined first
storage_providers:
  file_system:
    - id: "fs-services"
      path: "/services"

# ConnectRPC configuration
connect_rpc:
  enabled: true
  storage:
    provider_id: "fs-services"  # Must match a storage_providers.file_system[].id

For detailed information about router configuration options, including environment variables, storage providers, and advanced settings, see the Router Configuration documentation.

2. Run the router (docker example)

When running the router container, you must ensure:

Here is an example docker run command:

docker run \
  --name cosmo-router \
  -p 3002:3002 \
  -p 5026:5026 \
  -v "$(pwd)/config.yaml:/config/config.yaml:ro" \
  -v "$(pwd)/services:/services:ro" \
  ghcr.io/wundergraph/cosmo/router:latest

You will also need to pass any required environment variables (e.g., GRAPH_API_TOKEN) using -e flags.

3. Verification

When the router starts, it will scan the mounted directories. Look at the logs to verify it has successfully discovered your services and operations. You should see output similar to this:

INFO discovered service {"service": "HrService", "dir": "/services", "proto_files": 1, "operation_files": 3}
INFO loaded operations for service {"service": "employees.v1.HrService", "operation_count": 3}
INFO ConnectRPC server ready {"addr": "0.0.0.0:5026"}

Key indicators:

Your API is now ready to accept traffic via gRPC, Connect, and HTTP/JSON.