Trait Resolver

Source
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§

Source

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 information
  • directive - The directive associated with this field resolution
  • definition - The field definition containing metadata
  • inputs - The input values provided for this field
§Returns

Returns a Result containing either the resolved FieldOutput value or an Error

Source

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 information
  • directive - The directive associated with this subscription field
  • definition - The field definition containing metadata about the subscription
§Returns

Returns a Result containing either a boxed Subscriber implementation or an Error

Implementors§