Grafbase Dev Command

Run your federated graph in your local dev environment.

Usage:

grafbase dev [OPTIONS]

Options:

  • -r, --graph-ref <GRAPH_REF>: Graph reference following the format org/graph@branch
  • -c, --gateway-config <GATEWAY_CONFIG>: The path of the gateway configuration file.
  • -o, --graph-overrides <GRAPH_OVERRIDES>: The path of the graph overrides configuration file.
  • -p, --port <PORT>: The port to listen on for requests.

Run a federated graph:

grafbase dev --graph-ref my-org/my-graph@main

To run a federated graph with custom subgraphs, you can provide the overrides configuration file:

[subgraphs.products] introspection_url = "http://localhost:4000/graphql"
grafbase dev --graph-ref my-org/my-graph@main --graph-overrides overrides.toml

The dev command will start a gateway server on http://localhost:5000/graphql and a Pathfinder server on http://localhost:5000/ to load in the browser. The command will load all the subgraphs from my-org/my-graph@main togeteher with the local overrides, producing a federated schema to query against in the Pathfinder.

All changes to the subgraph will be automatically registered to the federated schema. The gateway server will also reload the schema when the subgraph changes.

You can add custom headers for the introspection call in your overrides configuration file:

[subgraphs.products.introspection_headers] authorization = "Bearer {{ env.PRODUCTS_ACCESS_TOKEN }}"

If you cannot introspect the subgraph, you can provide the schema file path in the overrides configuration file:

[subgraphs.products] schema_path = "/path/to/products.graphql"

If the port 5000 is not available, you can run the dev server on a different port:

grafbase dev --graph-ref my-org/my-graph@main --port 4000

The dev command accepts a gateway TOML configuration file to customize the gateway server. In this example we define a hooks WebAssembly file to be loaded by the gateway:

[hooks] location = "target/wasm32-wasip2/release/hooks.wasm"

Run the dev server with the custom gateway configuration:

grafbase dev --graph-ref my-org/my-graph@main --gateway-config grafbase.toml