Manifest-driven field selection for Lua-side queries.
Translates a fields tree supplied by a Lua script into the three things Ash needs:
select— the list of attribute atoms to pass toAsh.Query.select/2load— the load statement to pass toAsh.Query.load/2(orAsh.Changeset.load/2)template— an opaque structure the encoder walks to emit only the requested fields
The Lua side accepts a list of strings and one-key maps:
fields = {
"id", "title",
{ author = { "id", "name" } }, -- nested relationship
{ comments = { "id", "body" } }, -- has_many
{ title_prefixed = { args = { prefix = "x: " } } }, -- calc with args
{ metadata = { "priority", "category" } }, -- typed map sub-selection
{ coordinates = { "latitude", "longitude" } }, -- typed tuple
{ content = { text = { "body" } } }, -- union member sub-selection
}Default (no fields provided) returns primary-key attributes only for resource records.
For non-resource return types (typed map, tuple, primitive, etc.) the whole value is
rendered.
Type dispatch and template construction are driven entirely from
Ash.Info.Manifest.generate/1 IR — no Ash.Resource.Info.* traversal here.
Summary
Functions
Builds {select, load, template} for the given resource + action.
Parses a Lua-decoded fields input into the internal AST.
Functions
@spec for_action(Ash.Info.Manifest.t(), atom(), Ash.Info.Manifest.Action.t(), term()) :: {:ok, {[atom()], term(), term()}} | {:error, term()}
Builds {select, load, template} for the given resource + action.
requested is the already-decoded Lua input (the value of the fields key) — either
nil/empty (defaults apply) or a list of items produced by AshLua.Encoder.decode_input/1.
Parses a Lua-decoded fields input into the internal AST.
Returns {:ok, :default} when no fields were supplied, {:ok, ast} otherwise.