Discovers the associations of an Ecto schema through Ecto's compile-time reflection API — never a hand-maintained whitelist.
This module is the single source of truth the projection engine asks, at every recursion level: "is this field name a real association of the current schema, and if so, what schema do I recurse into?" It answers with zero configuration and zero drift — adding an association to a consumer schema makes it projectable automatically.
It is pure and database-free: only __schema__/1 and __schema__/2
reflection is used, so it can be exhaustively unit-tested without a repo and
sits comfortably under the middleware's per-operation overhead budget.
Example
iex> AbsintheProjector.Introspection.associations(MyApp.Order)
%{
customer: %AbsintheProjector.Introspection.Association{
name: :customer, kind: :belongs_to, related: MyApp.Customer
},
# ...
}embeds_one/embeds_many fields and scalar columns never appear — Ecto's
__schema__(:associations) already omits them.
Summary
Functions
Returns the %Association{} entry for name on schema, or nil when
name is not an association (e.g. a scalar field or an unknown identifier).
Returns a map of %Association{} metadata keyed by association name for the
given Ecto schema module.
Functions
@spec association(module(), atom()) :: AbsintheProjector.Introspection.Association.t() | nil
Returns the %Association{} entry for name on schema, or nil when
name is not an association (e.g. a scalar field or an unknown identifier).
Raises ArgumentError when schema is not an Ecto schema module.
@spec associations(module()) :: %{ required(atom()) => AbsintheProjector.Introspection.Association.t() }
Returns a map of %Association{} metadata keyed by association name for the
given Ecto schema module.
Returns an empty map (%{}) when the schema declares no associations.
Raises ArgumentError when schema is not an Ecto schema module.