AshIntrospection.TypeSystem.ResourceFields (AshIntrospection v0.3.0)
View SourceProvides 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.
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
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, []}
Gets the type and constraints for any field on a resource.
Checks attributes, calculations, relationships, and aggregates in order. Uses non-public Ash.Resource.Info functions to access all fields.
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, []}
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, []}