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 Subscriber>, 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 Subscriber>, Error>
fn resolve_subscription( &mut self, context: SharedContext, directive: Directive, definition: FieldDefinition, ) -> Result<Box<dyn Subscriber>, Error>
Resolves a subscription field based on the given context, directive, and definition.
The function should initialize a subscription internally, but not return any data.
Use the resolve_next_subscription_item method to retrieve the next item in the subscription.
§Arguments
context- The shared context containing runtime informationdirective- The directive associated with this subscriptiondefinition- The field definition containing metadata