zf

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

map_get.ex (582B)


      1 defmodule Absinthe.Middleware.MapGet do
      2   @moduledoc """
      3   This is the default middleware. It assumes the the object it receives is a map
      4   and uses `Map.get/2` to get the value for this field. If this field is already
      5   marked as resolved, then this middleware does not touch it.
      6 
      7   If you want to replace this middleware you should use
      8   `Absinthe.Schema.replace_default/4`
      9   """
     10 
     11   @behaviour Absinthe.Middleware
     12 
     13   def call(%{state: :unresolved, source: source} = res, key) do
     14     %{res | state: :resolved, value: Map.get(source, key)}
     15   end
     16 
     17   def call(res, _key), do: res
     18 end