Skip to content

Instantly share code, notes, and snippets.

@bruce
Created June 19, 2017 01:56
Show Gist options
  • Save bruce/69b9b86201994a31bd849971f44eb54b to your computer and use it in GitHub Desktop.
Save bruce/69b9b86201994a31bd849971f44eb54b to your computer and use it in GitHub Desktop.
A useful Absinthe resolve_type pattern
resolve_type fn
# Guess type from struct name:
# Example: %Foo{} -> :foo
%str{}, _ ->
str
|> Some.Helper.Module.struct_to_object_type
value, _ ->
Logger.warn "Could not extract type from value: #{inspect value}"
nil
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment