# `Grephql.TypeGenerator`
[🔗](https://github.com/fahchen/grephql/blob/v0.10.1/lib/grephql/type_generator.ex#L1)

Generates EctoTypedSchema embedded schema modules from GraphQL query AST.

Given an operation definition and a schema, generates per-query output type
modules with proper nesting, nullability, and field alias support.

## Naming convention

Output types follow per-query path naming under a `Result` namespace:

    ClientModule.FunctionName.Result.FieldName.NestedField...

Field aliases override both struct field names and module path segments.

## Union/Interface support

When a field's type is a union or interface, inline fragments determine
which concrete types to generate. Shared fields (outside fragments) are
merged into each concrete type's struct. A parameterized `Grephql.Types.Union`
Ecto Type handles `__typename`-based dispatch during deserialization.

# `option`

```elixir
@type option() ::
  {:client_module, module()}
  | {:function_name, atom()}
  | {:scalar_types, map()}
  | {:fragments, map()}
```

# `generate`

```elixir
@spec generate(Grephql.Language.OperationDefinition.t(), Grephql.Schema.t(), [
  option()
]) :: [module()]
```

Generates embedded schema modules for an operation's output types.

Returns a list of generated module names.

## Options

  - `:client_module` — the parent client module (e.g., `MyApp.UserService`)
  - `:function_name` — the defgql function name (e.g., `:get_user`)
  - `:scalar_types` — custom scalar type mappings (default: `%{}`)

# `generate_fragment`

```elixir
@spec generate_fragment(
  Grephql.Language.Fragment.t(),
  Grephql.Schema.t(),
  module(),
  map()
) :: module()
```

Generates an embedded schema module for a named fragment under
`ClientModule.Fragments.FragmentName`.

---

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