Selecto.Subfilter.JoinPathResolver (Selecto v0.4.5)

Copy Markdown

Resolve relationship paths into join sequences using domain join-path configuration.

This module expects a domain configuration with a flat joins map keyed by relationship paths (e.g. "orders.customer.name").

Summary

Functions

Resolve relationship path into join sequence using domain configuration.

Resolve multiple relationship paths at once for compound subfilters.

Validate that a relationship path can be resolved with the given domain configuration.

Functions

resolve(path, domain_name, base_table \\ nil)

@spec resolve(Selecto.Subfilter.RelationshipPath.t(), atom() | map(), atom() | nil) ::
  {:ok, Selecto.Subfilter.JoinPathResolver.JoinResolution.t()}
  | {:error, Selecto.Subfilter.Error.t()}

Resolve relationship path into join sequence using domain configuration.

Parameters

  • relationship_path - Parsed RelationshipPath struct
  • domain_name - Domain identifier or a domain join-path config map
  • base_table - Base table for the query (defaults to first segment of path)

Returns

| {:error, Subfilter.Error.t()}

resolve_multiple(paths, domain_name, base_table \\ nil)

@spec resolve_multiple(
  [Selecto.Subfilter.RelationshipPath.t()],
  atom() | map(),
  atom() | nil
) ::
  {:ok, [Selecto.Subfilter.JoinPathResolver.JoinResolution.t()]}
  | {:error, Selecto.Subfilter.Error.t()}

Resolve multiple relationship paths at once for compound subfilters.

This is more efficient than resolving paths individually when dealing with compound subfilters (AND/OR operations) as it can detect and reuse common join sequences.

validate_path(path, domain_name)

@spec validate_path(Selecto.Subfilter.RelationshipPath.t(), atom() | map()) ::
  :ok | {:error, Selecto.Subfilter.Error.t()}

Validate that a relationship path can be resolved with the given domain configuration.

This is useful for early validation before attempting to build queries.