Schema builder
gurafi::Schema<Ctx> collects object, interface, union, scalar and root declarations and turns
them into a gql::Schema. Configuration and type registration happen once, then build()
freezes the result.
Creating a schema
Ctx is the request context type. Use () when the schema does not need one.
The builder exposes:
Building
build() validates everything gql requires: duplicate names, dangling type references,
invalid interface implementations, input cycles, directive locations and argument types. It
returns every problem together as SchemaError.
For stable snapshots and generated clients, sort types by name:
Schema is Clone. Keep the declaration after building, or build repeatedly:
Registering types
Named types referenced by a field are registered automatically. Explicit registration is useful
for types that are part of the public schema without appearing in a field signature, and for
choosing a registration order when sort_types is off.
Plugins
Plugins are build-time field hooks. They see every object, interface, root and subscription field, can mutate field metadata, and can wrap resolvers and subscriptions. See Using plugins and Writing plugins.
Runtime-named types
Most GraphQL names are known from the Rust type. A reference separates the name from the model:
ObjectRef<M>, InterfaceRef and UnionRef are Clone but not Copy. The same name and model
merge; a different Rust model claiming a name is a build error. Runtime names must match the
GraphQL Name grammar; an invalid name is a build error.
Return a runtime-named object:
Use an explicit type reference when the field is abstract or the wrappers need to be spelled out:
field_ref_type checks that the wrappers are truthful for the Rust type and that the named type
exists. FieldConfig::as_dynamic(TypeRef) is the same operation on a field whose builder is not
available.
Directives
Register a definition once and apply it where it belongs:
type_directive works for objects, interfaces, unions, scalars, enums, input objects and root
types, including types registered later. argument_directive and input_field_directive cover
the remaining positions. See Directives.
Generated types
Error result unions register generated success objects and result unions from the parent type and
field name. Relay connections and payloads use runtime names. Both are ordinary schema types at
build time; Schema::build validates them like hand-written declarations.
Introspection and SDL
The returned schema is a gql::Schema, so introspection, execution and suku need no
gurafi-specific adapter. See Printing schemas.
