Overview
Interface types represent a list of named fields and their types. They define a contract that object types can implement, ensuring those objects include specific fields. Inherits from:Rails::GraphQL::Type
Specification: GraphQL Interface Type Definition
Class Attributes
The type of field class used for this interface’s fields
Collection of object types that implement this interface (managed automatically)
Class Methods
type_for(value, *)
Determine which implementing object type is compatible with the provided value.
The value to find a type for
Returns the first compatible object type, or
nil if none found=~(other)
Check if another type is equivalent to this interface.
The type to compare
Returns
true if the other type is equivalent or is an object that implements this interfaceimplemented(object, import_fields: true)
Called automatically when an object type implements this interface. You typically don’t call this directly.
The object type implementing this interface
Whether to copy interface fields to the object
Included Modules
Helpers::Instantiable
Provides instance creation capabilities
Helpers::WithAssignment
Allows assignment to Ruby classes
Helpers::WithFields
Provides field definition and management methods
Configuration
Special Features
Abstract Interfaces
When an interface is marked as abstract,import_fields is automatically set to false in the implemented method.
Validation
Interfaces skip field type validation during the validation phase, as fields are copied and interface field types might be broken due to namespaces.Type Resolution
Interfaces don’t implementvalid_output? or serialization methods directly. The object types that implement the interface handle validation and serialization.