Created
June 19, 2017 01:56
-
-
Save bruce/69b9b86201994a31bd849971f44eb54b to your computer and use it in GitHub Desktop.
A useful Absinthe resolve_type pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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