AshTypescript.Rpc.RequestedFieldsProcessor (ash_typescript v0.18.1)

Copy Markdown View Source

Processes requested fields for Ash resources, determining which fields should be selected vs loaded, and building extraction templates for result processing.

This module handles different action types:

  • CRUD actions (:read, :create, :update, :destroy) return resource records
  • Generic actions (:action) return arbitrary types as specified in their returns field

Architecture

Delegates to FieldSelector, which uses a unified type-driven recursive dispatch pattern (similar to ValueFormatter). Each type is self-describing via {type, constraints}, so no separate classification step is needed.

Manifest module

Field selection needs lookups (resources, actions, types) that live on an AshTypescript.Manifest module's persisted Spark DSL state. process/4 accepts an optional manifest module — when omitted, defaults to the configured production manifest module. Verifiers running against an inline test manifest pass their own module.

Summary

Functions

Atomizes requested fields by converting standalone strings to atoms and map keys to atoms.

Processes requested fields for a given resource and action.

Functions

atomize_requested_fields(requested_fields, resource \\ nil, manifest \\ nil)

Atomizes requested fields by converting standalone strings to atoms and map keys to atoms.

process(resource, action_name, requested_fields, manifest_module \\ nil, opts \\ [])

Processes requested fields for a given resource and action.

Returns {:ok, {select_fields, load_fields, extraction_template}} or {:error, error}.