Skuld.Query (skuld v0.27.3)
View SourcePrimary API for query contracts, wiring, and caching.
Defining a query contract
defmodule MyApp.Queries do
use Skuld.Query
deffetch get_user(id :: String.t()) :: User.t() | nil
deffetch get_orders(user_id :: String.t()) :: [Order.t()]
endWiring executors
comp
|> Skuld.Query.with_executor(MyApp.Queries, MyApp.Queries.EctoExecutor)
|> FiberPool.with_handler()
|> Comp.run()With caching
comp
|> Skuld.Query.with_cached_executor(MyApp.Queries, MyApp.Queries.EctoExecutor)
|> FiberPool.with_handler()
|> Comp.run()
Summary
Functions
Install a caching-wrapped executor for a single contract.
Shorthand for with_cached_executors/2.
Install caching-wrapped executors for multiple contracts. Initialises a scoped cache and wraps executors so identical queries return cached results without re-executing.
Install an executor module for a single query contract.
Install executor modules for multiple query contracts.
Accepts either a list of {contract_module, executor_module} tuples or a map.
Functions
Install a caching-wrapped executor for a single contract.
Shorthand for with_cached_executors/2.
Install caching-wrapped executors for multiple contracts. Initialises a scoped cache and wraps executors so identical queries return cached results without re-executing.
@spec with_executor(Skuld.Comp.Types.computation(), module(), module()) :: Skuld.Comp.Types.computation()
Install an executor module for a single query contract.
The executor module must implement the contract's callbacks.
Install executor modules for multiple query contracts.
Accepts either a list of {contract_module, executor_module} tuples or a map.