# `Arcadic.Result`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/result.ex#L5)

Normalizes an ArcadeDB statement response into rows or a graph.

Removes the serializer's `@props` field from each row. Retains the
record and graph identity fields `@rid`, `@type`, `@cat`, `@in`,
and `@out`.

The HTTP graph serializer returns a graph with vertex and edge lists.
Each element keeps its server-defined fields.

An EXPLAIN/PROFILE envelope carries its plan under `explainPlan` (never `result`),
so `normalize/1` returns `{:error, %Arcadic.Error{reason: :use_explain}}` for it
rather than a silent empty row set. The plan surface is `normalize_plan/1`,
consumed by `Arcadic.explain/4` and `Arcadic.profile/4`.

# `graph`

```elixir
@type graph() :: %{vertices: [map()], edges: [map()]}
```

# `t`

```elixir
@type t() :: [map()] | graph()
```

# `normalize`

```elixir
@spec normalize(map()) :: {:ok, t()} | {:error, Arcadic.Error.t()}
```

Extract `result`, returning a graph or a list of rows with `@props` removed.

## Examples

    iex> Arcadic.Result.normalize(%{"result" => [%{"n" => 1, "@props" => "n:1"}]})
    {:ok, [%{"n" => 1}]}

# `normalize_plan`

```elixir
@spec normalize_plan(map()) ::
  {:ok, %{plan: String.t(), plan_tree: map(), rows: [map()]}}
```

Extract the EXPLAIN/PROFILE plan envelope: `{:ok, %{plan, plan_tree, rows}}`.

## Examples

    iex> Arcadic.Result.normalize_plan(%{"explain" => "plan", "explainPlan" => %{}, "result" => []})
    {:ok, %{rows: [], plan: "plan", plan_tree: %{}}}

---

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