# `mix nebula_graph_ex.gen.graph`
[🔗](https://github.com/VChain/nebula_graph_ex/blob/v0.1.10/lib/mix/tasks/nebula_graph_ex.gen.graph.ex#L1)

The recommended way to set up `nebula_graph_ex` in your application.

Generates a `NebulaGraphEx.Graph` module scoped to your OTP app, adds a
default config block to `config/config.exs`, registers the module in your
application's supervision tree, and integrates NebulaGraphEx telemetry with
Phoenix telemetry metrics when available.

## Usage

    mix nebula_graph_ex.gen.graph MyApp.Graph

The module name becomes both the Elixir module and the registered connection
pool name. Running the generator:

1. Creates `lib/my_app/graph.ex` — the graph module
2. Inserts a default config block into `config/config.exs`
3. Injects the module as the first child in `lib/my_app/application.ex`
4. Adds NebulaGraphEx metrics to `lib/my_app_web/telemetry.ex` when present
5. Adds LiveDashboard metrics wiring when a dashboard route is present
6. Prints a `config/runtime.exs` snippet for secrets

All three file modifications are idempotent — re-running the generator on an
already-configured app skips each step that is already in place.

The file path for the graph module is derived automatically from the module
name. Use `--path` to override it if your project layout differs from the
standard convention:

    mix nebula_graph_ex.gen.graph MyApp.Graph --path lib/my_app/connections/graph.ex

## Multiple connections

Run the generator once per graph module:

    mix nebula_graph_ex.gen.graph MyApp.PrimaryGraph
    mix nebula_graph_ex.gen.graph MyApp.AnalyticsGraph

Each module manages its own connection pool and reads its config from
`Application.get_env(:my_app, MyApp.PrimaryGraph)` independently.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
