Compose generates the router execution config locally from your subgraphs. The config can be used to start your router with a pre-built router config.

IMPORTANT: Please note that since this command runs locally, the subgraphs may or may not exist on the control plane. It is recommended to not use this for production, if you plan to use the Cosmo platform as schema registry or analytics platform. For production, you can fetch the latest router execution config for your federated graph using the fetch command instead.


npx wgc router compose -i <path-to-input-file>


The npx wgc router compose command allows you to compose subgraphs and build a router execution config locally without a connection to the control plane.


  • -i, --input: The path to the input config file that contains information about your subgraphs.

  • -o, --out : Destination file for the router config. Prints to standard output if not provided.

Input file structure

version: 1
  # You can either provide schema file or introspection. File takes precedence
  - name: employees
    routing_url: http://localhost:4001/graphql
      file: ./employees.graphql
      url: http://localhost:4001/sse #Optional, defaults to routing_url
      protocol: sse # Optional, defaults to ws (websockets)
      websocket_subprotocol: graphql-ws # Optional, defaults to auto. 
      # Available options are auto, graphql-ws, graphql-transport-ws
  - name: family
    routing_url: http://localhost:4002/graphql
      url: http://localhost:4002/graphql
        Authorization: 'Bearer YOUR_TOKEN_HERE'


npx wgc router compose -i graph.yaml

Compose subgraphs mentioned in the input file graph.yaml

npx wgc router compose -i graph.yaml -o config.json

Compose subgraphs mentioned in graph.yaml and write it to config.json


  • The npx wgc router compose command does not interact with the control plane and completely runs locally.

Last updated