View Source Bonfire.Common.QueryModule behaviour (bonfire_umbrella v0.3.6-classic-beta.7)

Properly query some data using the appropriate module depending on its schema.

Back by a global cache of known query_modules to be queried by their schema, or vice versa.

Use of the QueryModule Service requires:

  1. Exporting query_module/0 in relevant modules (in schemas pointing to query modules and/or in query modules pointing to schemas), returning a Module atom
  2. To populate :pointers, :search_path in config the list of OTP applications where query_modules are declared.
  3. Start the Bonfire.Common.QueryModule application before querying.
  4. OTP 21.2 or greater, though we recommend using the most recent release available.

While this module is a GenServer, it is only responsible for setup of the cache and then exits with :ignore having done so. It is not recommended to restart the service as this will lead to a stop the world garbage collection of all processes and the copying of the entire cache to each process that has queried it since its last local garbage collection.

Link to this section Summary

Callbacks

Points to the related context module

Declares a query module

Points to the related schema module

Link to this section Callbacks

@callback context_module() :: atom()

Points to the related context module

@callback query_module() :: any()

Declares a query module

@callback schema_module() :: atom()

Points to the related schema module

Link to this section Functions

Link to this function

apply_error(error, args)

View Source
Link to this function

linked_context_modules()

View Source
Link to this function

maybe_query(schema, filters \\ [], fallback_fun \\ &apply_error/2)

View Source
Link to this function

maybe_query_module(query)

View Source
@spec modules() :: [atom()]

Callback implementation for Bonfire.Common.ExtensionBehaviour.modules/0.

Link to this function

query_function_error(error, args, level \\ :info)

View Source

Look up a Queryable by name or id, throw :not_found if not found.

Get a Queryable identified by name or id.

@spec query_modules([binary() | atom()]) :: [binary()]

Look up many ids at once, throw :not_found if any of them are not found