AshDyan.Engine.Hook behaviour (AshDyan v0.6.0)

Copy Markdown View Source

Behaviour for pipeline hooks.

Hook modules can be registered in config:

config :ash_dyan, :hooks, %{
  before_query: [MyApp.Hooks.BeforeQuery],
  after_query: [MyApp.Hooks.AfterQuery],
  before_format: [MyApp.Hooks.BeforeFormat],
  after_format: [MyApp.Hooks.AfterFormat]
}

Each hook receives the accumulator, request, and options, and returns the modified accumulator.

Summary

Callbacks

after_format(t, t, keyword)

@callback after_format(AshDyan.Result.t(), AshDyan.Request.t(), keyword()) ::
  AshDyan.Result.t()

after_query(list, t, keyword)

@callback after_query([Ash.Resource.Record.t()], AshDyan.Request.t(), keyword()) :: [
  Ash.Resource.Record.t()
]

before_format(list, t, keyword)

@callback before_format([Ash.Resource.Record.t()], AshDyan.Request.t(), keyword()) :: [
  Ash.Resource.Record.t()
]

before_query(t, t, keyword)

@callback before_query(Ash.Query.t(), AshDyan.Request.t(), keyword()) :: Ash.Query.t()