Compose - WunderGraph

Usage

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

Description

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.

Options

Note: The --split-configs-enabled flag requires Router version 0.315.0 or higher.

Input file structure

version: 1
subgraphs:
  # You can either provide schema file or introspection. File takes precedence
  - name: employees
    routing_url: http://localhost:4001/graphql
    schema:
      file: ./employees.graphql
    subscription:
      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
    introspection:
      url: http://localhost:4002/graphql
      headers:
        Authorization: 'Bearer YOUR_TOKEN_HERE'

Feature flags (optional)

You can define feature flags in the input file so the composed router config includes alternate subgraphs when a flag is active. Each flag lists one or more feature_graphs that describe the replacement subgraph to serve when the flag is enabled (e.g. via the X-Feature-Flag header). For an overview of how the router uses feature flags, see Feature Flags.

feature_flags:
  - name: test_checkout
    feature_graphs:
      - name: checkout_canary
        subgraph_name: checkout
        routing_url: https://api.example.com/checkout-canary/graphql
        schema:
          file: feature-flag_checkout.graphql
subgraphs:
  - name: checkout
    routing_url: https://api.example.com/checkout/graphql
    schema:
      file: checkout.graphql

Examples

npx wgc router compose -i graph.yaml

Compose subgraphs mentioned in the input file graph.yaml

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

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

Notes