pub trait Resolver: Extension {
// Required methods
fn resolve_field(
&mut self,
context: SharedContext,
directive: Directive,
definition: FieldDefinition,
inputs: FieldInputs,
) -> Result<FieldOutput, Error>;
fn resolve_subscription(
&mut self,
context: SharedContext,
directive: Directive,
definition: FieldDefinition,
) -> Result<Box<dyn Subscription>, Error>;
}Expand description
A trait that extends Extension and provides functionality for resolving fields.
Implementors of this trait are expected to provide a method to resolve field values based on the given context, directive, and inputs. This is typically used in scenarios where field resolution logic needs to be encapsulated within a resolver object, allowing for modular and reusable code design.
Required Methods§
Sourcefn resolve_field(
&mut self,
context: SharedContext,
directive: Directive,
definition: FieldDefinition,
inputs: FieldInputs,
) -> Result<FieldOutput, Error>
fn resolve_field( &mut self, context: SharedContext, directive: Directive, definition: FieldDefinition, inputs: FieldInputs, ) -> Result<FieldOutput, Error>
Resolves a field value based on the given context, directive, definition, and inputs.
§Arguments
context- The shared context containing runtime informationdirective- The directive associated with this field resolutiondefinition- The field definition containing metadatainputs- The input values provided for this field
§Returns
Returns a Result containing either the resolved FieldOutput value or an Error
Sourcefn resolve_subscription(
&mut self,
context: SharedContext,
directive: Directive,
definition: FieldDefinition,
) -> Result<Box<dyn Subscription>, Error>
fn resolve_subscription( &mut self, context: SharedContext, directive: Directive, definition: FieldDefinition, ) -> Result<Box<dyn Subscription>, Error>
Resolves a subscription field by setting up a subscription handler.
§Arguments
context- The shared context containing runtime informationdirective- The directive associated with this subscription fielddefinition- The field definition containing metadata about the subscription
§Returns
Returns a Result containing either a boxed Subscriber implementation or an Error