Interfaces
An interface declares fields that several object types share. Clients can select the interface and use inline fragments for concrete fields.
Rust models stay concrete. The executor asks the object's generated is_type_of check (or the
interface's resolve_type hook) which GraphQL type a value belongs to.
Define an interface
Interface fields have no resolvers. Execution uses the concrete object's field resolver.
Implement it
implements is idempotent and also accepts a runtime InterfaceRef. An object may implement
several interfaces.
Interface fields can be declared once and inherited by the object:
At build time the matching interface field supplies the type, arguments, description, deprecation reason and directives when the object did not set them. The build verifies that the resolver's argument type matches the interface declaration.
Interfaces can implement other interfaces:
An object that implements Resource also implements Node; there is no need to repeat the
transitive interface.
Abstract fields
A field returning an interface or union declares its abstract type with as_abstract:
For a runtime interface name, use interface_ref and the same method:
Resolving the concrete type
The generated ObjectModel implementation supplies is_type_of, so a model that travels as
Value::External is recognised without extra code. Install resolve_type when the value is not a
Rust model, for example a raw map or an enum-shaped DTO:
resolve_type returns a GraphQL type name. It runs before field completion for an abstract
position and its error becomes a field error.
Authorization
Interface rules are inherited by implementing objects and their fields:
All applicable rules must allow the request: the object's own rule, the field's rule, and every implemented interface's rule. See Scope auth.
Possible types
For a built schema, use the reference helpers:
These answer the same question as the built schema's abstract type map and are useful in code that constructs fragments or client metadata.
