# `Grephql.Types.Union`
[🔗](https://github.com/fahchen/grephql/blob/v0.10.1/lib/grephql/types/union.ex#L1)

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`.

# `define`

```elixir
@spec define(module(), %{required(String.t()) =&gt; module()}) ::
  {:module, module(), binary(), term()}
```

Defines a parameterized Ecto Type module for a GraphQL union/interface.

Called by the type generator at compile time. `typename_to_module` maps
GraphQL `__typename` strings to their corresponding embedded schema modules.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
