MishkaGervaz.Table.Web.DataLoader.QueryBuilder (MishkaGervaz v0.0.1-alpha.3)

Copy Markdown View Source

Builds Ash queries with filters and sorting from table state.

Overridable Functions

  • build_query/1 - Build complete query from state
  • apply_filters_to_query/4 - Apply filter values to query with state context
  • apply_sorting_to_query/2 - Apply sort fields to query
  • apply_default_filter/3 - Apply filter when no type_module is configured
  • build_apply_context/1 - Build context map passed to apply functions

User Override

defmodule MyApp.Table.DataLoader.QueryBuilder do
  use MishkaGervaz.Table.Web.DataLoader.QueryBuilder

  def apply_default_filter(query, field, value) when is_binary(value) do
    Ash.Query.filter(query, ^ref(field) == ^value)
  end
end

See MishkaGervaz.Table.Web.DataLoader, MishkaGervaz.Table.Web.DataLoader.Helpers, MishkaGervaz.Table.Types.Filter, and the sibling sub-builders FilterParser, PaginationHandler, TenantResolver, HookRunner, RelationLoader.