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 — currently
TypedGql.Generation.Plugins.SkipInclude for @include/@skip — before the
ones given in the :generation_plugins option, in order, at each juncture.
TypedGql.TypeGenerator describes what each step does.
Summary
Types
What Module.create/3 is handed to record where a generated module came
from: the caller's Macro.Env, or a keyword list carrying :file/:line.
Callbacks
Runs on the {module, quoted_ast, create_opts} triples produced by lowering,
where create_opts is what Module.create/3 is handed to record where the
generated module came from.
Runs on the canonical selections produced by normalization (fragment spreads expanded, inline fragments flattened, ancestor directives propagated onto each field).
Runs on the generated-schema tree produced by resolution.
Runs on the raw selections before normalization.
Types
@type module_create_opts() :: Macro.Env.t() | keyword()
What Module.create/3 is handed to record where a generated module came
from: the caller's Macro.Env, or a keyword list carrying :file/:line.
@type selection() :: TypedGql.Language.Field.t() | TypedGql.Language.InlineFragment.t() | TypedGql.Language.FragmentSpread.t()
Callbacks
@callback after_lower( [{module(), Macro.t(), module_create_opts()}], TypedGql.Generation.Context.t() ) :: [ {module(), Macro.t(), module_create_opts()} ]
Runs on the {module, quoted_ast, create_opts} triples produced by lowering,
where create_opts is what Module.create/3 is handed to record where the
generated module came from.
@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).
@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.
@callback before_normalize([selection()], TypedGql.Generation.Context.t()) :: [ selection() ]
Runs on the raw selections before normalization.