Dynamic parameterized Ecto Type for GraphQL union/interface types.
Dispatches to the correct embedded schema module based on the
__typename field in the JSON map.
The generated module implements Ecto.ParameterizedType and uses
embed_as: :dump so that Ecto.embedded_load/3 calls load/3,
which reads __typename and delegates to the matched module via
Ecto.embedded_load/3.
An unresolvable __typename returns :error, as the callback contract
requires; Ecto turns that into its own ArgumentError naming the offending
map, the field and the schema, so nothing is lost by not carrying a message.
cast/2 accepts the wire shape — a decoded JSON map with a string
"__typename" — and reads the values inside the variant with load
semantics, so an already-cast value such as an enum atom is not accepted.
Summary
Functions
The body of a parameterized Ecto Type module for a GraphQL union/interface.
Functions
The body of a parameterized Ecto Type module for a GraphQL union/interface.
Called by the type generator at compile time, which creates the module from
it alongside the embedded schemas, so that this one records the caller's
source location like the rest. typename_to_module maps GraphQL
__typename strings to their corresponding embedded schema modules.