Skip to main content

Connect to your subgraphs running on localhost from Docker

A common setup for development is running subgraphs on localhost and the executing router inside Docker. To avoid requiring additional configuration steps in this environment and to make this setup more ergonomic, when running inside Docker the router will retry requests that fail to connect to a loopback address, sending them to docker.host.internal instead. This feature is enabled by default, but it can be disabled by setting the environment variable LOCALHOST_FALLBACK_INSIDE_DOCKER to false.

Hot reload the router configuration file

When working on the router configuration without changing router versions, custom modules, etc, it can be helpful to enable hot reloading of the configuration file.
Config watcher hot reloading is not recommended for production. A reload, triggered by watch_config or by SIGHUP, stops the running router before it starts a new one with the updated configuration:
  • The router stops accepting connections until the new router is listening. Clients receive connection errors in the meantime.
  • In-flight requests have at most shutdown_delay to complete. WebSocket and SSE subscriptions are closed.
  • If the new router fails to start, the process exits. The previous router is not kept running. Causes include an invalid TLS certificate, a port that is already in use, or an execution config that cannot be fetched at reload time.
  • If the configuration file fails to load or validate, the router restarts with the previous configuration.
In production, roll out router configuration changes by redeploying the router instances. Execution config updates, from the CDN or execution_config.file.watch, do not restart the router and keep accepting connections. They close long-lived WebSocket and SSE subscriptions, so clients must reconnect. See Config Hot Reload.
You can enable file watching based hot config reloading using the following configuration:
config.yaml
Alternatively, the router will always reload when it receives a SIGHUP signal. You can do this on MacOS/Linux using kill -HUP <pid>.
Hot reloading has some limitations:
  • Changes to the watch_config section are not hot-reloaded.
  • Changes to flags and environment variables are not possible.
  • watch_config based reloads are based on the filesystem’s modification time, edits that somehow circumvent this mechanism will not trigger a reload.