zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

plugin.ex (1821B)


      1 defmodule Absinthe.Plugin do
      2   @moduledoc """
      3   Plugin Behaviour
      4 
      5   Plugins are an additional set of callbacks that can be used by module based
      6   middleware to run actions before and after resolution, as well as add additional
      7   phases to run after resolution
      8   """
      9 
     10   @type t :: module
     11 
     12   @doc """
     13   callback to setup the resolution accumulator prior to resolution.
     14 
     15   NOTE: This function is given the full accumulator. Namespacing is suggested to
     16   avoid conflicts.
     17   """
     18   @callback before_resolution(execution :: Absinthe.Blueprint.Execution.t()) ::
     19               Absinthe.Blueprint.Execution.t()
     20 
     21   @doc """
     22   callback to do something with the resolution accumulator after
     23   resolution.
     24 
     25   NOTE: This function is given the full accumulator. Namespacing is suggested to
     26   avoid conflicts.
     27   """
     28   @callback after_resolution(execution :: Absinthe.Blueprint.Execution.t()) ::
     29               Absinthe.Blueprint.Execution.t()
     30 
     31   @doc """
     32   callback used to specify additional phases to run.
     33 
     34   Plugins may require additional resolution phases to be run. This function should
     35   use values set in the resolution accumulator to determine
     36   whether or not additional phases are required.
     37 
     38   NOTE: This function is given the whole pipeline to be inserted after the current
     39   phase completes.
     40   """
     41   @callback pipeline(
     42               next_pipeline :: Absinthe.Pipeline.t(),
     43               execution :: Absinthe.Blueprint.Execution.t()
     44             ) ::
     45               Absinthe.Pipeline.t()
     46 
     47   @doc """
     48   Returns the list of default plugins.
     49   """
     50   def defaults() do
     51     [Absinthe.Middleware.Batch, Absinthe.Middleware.Async]
     52   end
     53 
     54   @doc false
     55   def pipeline(plugins, exec) do
     56     Enum.reduce(plugins, [], fn plugin, pipeline ->
     57       plugin.pipeline(pipeline, exec)
     58     end)
     59     |> Enum.dedup()
     60     |> List.flatten()
     61   end
     62 end