Condiment v0.1.2 Condiment View Source

Add flavors to your context APIs easily!

No need to create different functions to cater to different use cases, instead you can have one single public function and add flavors conditionally, with Condiment.

Link to this section Summary

Functions

field is what you allow users to query for. The resolver is how to resolve that query.

To use Condiment, you start with the Condiment.new/2,3 interface.

Runs all of the resolvers conditionally based on what user requested, it runs in the order that you defined (not the order the user supplied).

Link to this section Types

Specs

t() :: %Condiment{
  condiment_opts: list(),
  opts: list(),
  resolvers: list(),
  token: any()
}

Link to this section Functions

Link to this function

add(condiment, key, resolver)

View Source

Specs

add(t(), atom(), (any(), map() -> any())) :: t()

field is what you allow users to query for. The resolver is how to resolve that query.

The resolver has to be 2-arity, the first argument is the the result of the previously ran resolver (the first resolver gets token instead).

Link to this function

new(token, opts, condiment_opts \\ [])

View Source

Specs

new(any(), list(), list()) :: t()

To use Condiment, you start with the Condiment.new/2,3 interface.

The currently available options for condiment_opts is:

  • :on_unknown_fields one of:nothing,:error, or:raise` (default). This option specify what to do when user supplies a field that's not resolvable.

Specs

run(t()) :: any()

Runs all of the resolvers conditionally based on what user requested, it runs in the order that you defined (not the order the user supplied).