Provides unified resource field type lookup.
This module centralizes the logic for looking up field types from Ash resources, supporting attributes, calculations, relationships, and aggregates.
Variants
get_field_type_info/2- Looks up any field (public or private)get_public_field_type_info/2- Looks up only public fields
Both return {type, constraints} tuples, with {nil, []} for unknown fields.
Every lookup goes through AshIntrospection.ResourceInfo, so an optional
trailing config carrying a :manifest key answers from the manifest
instead. Omitting it reads live Ash.Resource.Info, which is what every
caller does today.
Summary
Functions
Gets the resolved type for an aggregate field.
Gets the type and constraints for any field on a resource.
Gets the type and constraints for public fields only.
Functions
@spec get_aggregate_type_info( module(), atom(), AshIntrospection.ResourceInfo.config() ) :: {atom() | nil, keyword()}
Gets the resolved type for an aggregate field.
Aggregates can have computed types based on the underlying field type. This function returns the fully resolved aggregate type.
Examples
iex> get_aggregate_type_info(MyApp.User, :todo_count)
{Ash.Type.Integer, []}
@spec get_field_type_info(module(), atom(), AshIntrospection.ResourceInfo.config()) :: {atom() | tuple() | nil, keyword()}
Gets the type and constraints for any field on a resource.
Checks attributes, calculations, relationships, and aggregates in order. Reaches private fields as well as public ones.
Examples
iex> get_field_type_info(MyApp.User, :name)
{Ash.Type.String, []}
iex> get_field_type_info(MyApp.User, :todos)
{{:array, MyApp.Todo}, []}
iex> get_field_type_info(MyApp.User, :unknown)
{nil, []}
@spec get_public_field_type_info( module(), atom(), AshIntrospection.ResourceInfo.config() ) :: {atom() | tuple() | nil, keyword()}
Gets the type and constraints for public fields only.
Checks public attributes, calculations, aggregates, and relationships in order. Used for output formatting where we only want publicly accessible fields.
Examples
iex> get_public_field_type_info(MyApp.User, :name)
{Ash.Type.String, []}
iex> get_public_field_type_info(MyApp.User, :private_field)
{nil, []}