# `Exograph`
[🔗](https://github.com/elixir-vibe/exograph/blob/v0.2.0/lib/exograph.ex#L1)

Local CodeQL-style code search for Elixir, backed by Postgres and ExAST.

## Quick start

    {:ok, index} = Exograph.index("lib", repo: MyApp.Repo, migrate?: true)
    {:ok, hits} = Exograph.search(index, "Repo.get!(_, _)")

## DSL queries

    import Exograph.DSL
    query = from(f in Fragment, where: matches(f, "def _ do ... end"))
    {:ok, hits} = Exograph.all(index, query)

## Call graph

    {:ok, callers} = Exograph.search_callers(index, "Repo.transaction/1")
    {:ok, callees} = Exograph.search_callees(index, "MyApp.create_user/1")

# `all`

```elixir
@spec all(Exograph.Index.t(), Exograph.DSL.Query.t(), keyword()) ::
  {:ok, [map()]} | {:error, term()}
```

# `index`

```elixir
@spec index(
  String.t() | [String.t()],
  keyword()
) :: {:ok, Exograph.Index.t()} | {:error, term()}
```

# `search`

```elixir
@spec search(
  Exograph.Index.t() | term(),
  ExAST.Pattern.pattern() | ExAST.Selector.t(),
  keyword()
) ::
  {:ok, [map()]} | {:error, term()}
```

# `search_callees`

```elixir
@spec search_callees(Exograph.Index.t(), String.t(), keyword()) ::
  {:ok, [Exograph.CallEdge.t()]}
```

# `search_callers`

```elixir
@spec search_callers(Exograph.Index.t(), String.t(), keyword()) ::
  {:ok, [Exograph.CallEdge.t()]}
```

---

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