TypedGql.Types.Typename (TypedGql v0.13.0)

Copy Markdown View Source

Parameterized Ecto Type for GraphQL __typename fields.

Converts GraphQL type name strings (e.g., "User", "SearchResult") to snake_cased Elixir atoms (e.g., :user, :search_result).

Both directions of the mapping are pre-computed at compile time in init/1, so at runtime cast/2, load/3 and dump/3 perform only a Map.fetch/2 lookup and dump/3 is the inverse of load/3.

Usage in schema

field :__typename, TypedGql.Types.Typename, values: ["User", "Post"]

Ecto calls init/1 automatically with the field options.

Summary

Types

t()

@type t() :: atom()