reformat_descriptions.ex (588B)
1 defmodule Absinthe.Phase.Schema.ReformatDescriptions do 2 @moduledoc false 3 4 # Trim all Descriptions 5 6 use Absinthe.Phase 7 alias Absinthe.Blueprint 8 9 @spec run(Blueprint.t(), Keyword.t()) :: {:ok, Blueprint.t()} 10 def run(input, _options \\ []) do 11 node = Blueprint.prewalk(input, &handle_node/1) 12 {:ok, node} 13 end 14 15 @spec handle_node(Blueprint.node_t()) :: Blueprint.node_t() 16 defp handle_node(%{description: description} = node) 17 when is_binary(description) do 18 %{node | description: String.trim(description)} 19 end 20 21 defp handle_node(node) do 22 node 23 end 24 end