underscore.ex (656B)
1 defmodule Absinthe.Adapter.Underscore do 2 @moduledoc """ 3 Underscores external input and leaves external input alone. Unlike the 4 `Absinthe.Adapter.Passthrough` this does not break introspection (because 5 introspection relies on underscoring incoming introspection queries which we 6 still do). 7 """ 8 9 use Absinthe.Adapter 10 11 def to_internal_name(nil, _role) do 12 nil 13 end 14 15 def to_internal_name("__" <> camelized_name, role) do 16 "__" <> to_internal_name(camelized_name, role) 17 end 18 19 def to_internal_name(camelized_name, _role) do 20 camelized_name 21 |> Macro.underscore() 22 end 23 24 def to_external_name(name, _role) do 25 name 26 end 27 end