# `TypedGql.Generation.Plugin`
[🔗](https://github.com/fahchen/typed_gql/blob/v0.11.0/lib/typed_gql/generation/plugin.ex#L1)

Behaviour for hooking into the response-type generation pipeline.

Generation runs as four named steps — `normalize`, `resolve`, `lower`,
`create`. Plugins observe/transform the output of the first three via
`after_normalize`, `after_resolve`, and `after_lower` (plus
`before_normalize` for the raw entry). Adjacent `before_X` equals
`after_prev`, so only the `after_*` family and `before_normalize` are
exposed. The terminal `create` step compiles modules and is not hookable.

All callbacks are optional. `use TypedGql.Generation.Plugin` provides
identity defaults and `defoverridable`, so a plugin only implements the
hooks it cares about (the built-in `@include`/`@skip` plugin implements
only `after_resolve`).

TypedGql always runs its built-in plugins before user plugins, in order,
at each juncture.

# `selection`

```elixir
@type selection() ::
  TypedGql.Language.Field.t()
  | TypedGql.Language.InlineFragment.t()
  | TypedGql.Language.FragmentSpread.t()
```

# `after_lower`
*optional* 

```elixir
@callback after_lower([{module(), Macro.t()}], TypedGql.Generation.Context.t()) :: [
  {module(), Macro.t()}
]
```

Runs on the `{module, quoted_ast}` pairs produced by lowering.

# `after_normalize`
*optional* 

```elixir
@callback after_normalize([selection()], TypedGql.Generation.Context.t()) :: [selection()]
```

Runs on the canonical selections produced by normalization (fragment
spreads expanded, inline fragments flattened, ancestor directives
propagated onto each field).

# `after_resolve`
*optional* 

```elixir
@callback after_resolve(TypedGql.Generation.Schema.t(), TypedGql.Generation.Context.t()) ::
  TypedGql.Generation.Schema.t()
```

Runs on the generated-schema tree produced by resolution.

This is where directive plugins like `@include`/`@skip` operate, since
it is the last juncture before field types are lowered.

# `before_normalize`
*optional* 

```elixir
@callback before_normalize([selection()], TypedGql.Generation.Context.t()) :: [
  selection()
]
```

Runs on the raw selections before normalization.

---

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