# `PgRest.Function.Introspect`
[🔗](https://github.com/agoodway/pgrest/blob/v0.2.0/lib/pg_rest/function/introspect.ex#L1)

Loads `PgRest.Function`s from `pg_proc`, in one statement.

Only plain functions (`prokind = 'f'`) of the given schemas are read. Extension-owned
functions and functions returning `trigger`, `event_trigger` or `internal` are always
skipped. The filter narrows further:

  * `only:` keeps exactly the listed names, `except:` drops them (matched as strings)
  * `as_role:` keeps a function only when at least one listed role may `EXECUTE` it

Every name and role is a bind parameter, and the statement runs with the statement options
of `Executor.repo_opts/2` (internal) (`log: false`, no repo query event), like every other
PgRest statement. Types are `pg_catalog.format_type(oid, NULL)` text under an empty
`search_path` (`Catalog.with_empty_search_path/3` (internal), as every catalog load), so every
type outside `pg_catalog` is schema qualified (`test.status_enum`, `public.user_status`).
Each result column also carries its `pg_type.typcategory` (`PgRest.Function.Return`
`categories`).

## Differences from PostgREST

Extension-owned functions are never exposed, even when EXECUTE is granted.
This keeps extension infrastructure outside the application RPC surface.

# `filter`

```elixir
@type filter() :: %{
  optional(:only) =&gt; [String.t()] | nil,
  optional(:except) =&gt; [String.t()],
  optional(:as_role) =&gt; [String.t()] | nil
}
```

# `load`

```elixir
@spec load(module(), [String.t()], [map()], filter()) ::
  {:ok, [PgRest.Function.t()]} | {:error, Exception.t()}
```

The functions of `schemas` that `filter` keeps. A composite return whose type is the table
of one of `resource_configs` carries that resource. A database or connection failure is
`{:error, exception}`.

---

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