zf

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

list.ex (1232B)


      1 defmodule Absinthe.Blueprint.Input.List do
      2   @moduledoc false
      3 
      4   alias Absinthe.{Blueprint, Phase, Type}
      5 
      6   @enforce_keys [:items]
      7   defstruct [
      8     :items,
      9     :source_location,
     10     # Added by phases
     11     flags: %{},
     12     schema_node: nil,
     13     errors: []
     14   ]
     15 
     16   @type t :: %__MODULE__{
     17           items: [Blueprint.Input.Value.t()],
     18           flags: Blueprint.flags_t(),
     19           schema_node: nil | Absinthe.Type.t(),
     20           source_location: Blueprint.SourceLocation.t(),
     21           errors: [Phase.Error.t()]
     22         }
     23 
     24   @doc """
     25   Wrap another input node in a list.
     26   """
     27   @spec wrap(Blueprint.Input.t(), Absinthe.Type.List.t()) :: t
     28   def wrap(%__MODULE__{} = list, _), do: list
     29 
     30   def wrap(node, list_schema_node) do
     31     %__MODULE__{
     32       items: wrapped_items(node),
     33       source_location: node.source_location,
     34       schema_node: list_schema_node
     35     }
     36   end
     37 
     38   @spec wrapped_items(Blueprint.Input.t()) :: [] | [Blueprint.Input.Value.t()]
     39   defp wrapped_items(%Blueprint.Input.Null{}) do
     40     []
     41   end
     42 
     43   defp wrapped_items(node) do
     44     [
     45       %Blueprint.Input.Value{
     46         raw: %Blueprint.Input.RawValue{content: node},
     47         normalized: node,
     48         schema_node: Type.unwrap(node.schema_node)
     49       }
     50     ]
     51   end
     52 end