Trait Resolver

Source
pub trait Resolver: Extension {
    // Required method
    fn resolve_field(
        &mut self,
        context: SharedContext,
        directive: Directive,
        definition: FieldDefinition,
        inputs: FieldInputs,
    ) -> Result<FieldOutput, 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 using the provided context, directive, and input values.

§Arguments
  • context - A reference to a shared context that contains any necessary state or environment information needed for resolution.
  • directive - The directive associated with the field being resolved. Directives can modify how fields are resolved, providing additional instructions or constraints.
  • inputs - A vector of FieldInput values that provide input parameters required for resolving the field.
§Returns

This method returns a Result which is:

  • Ok(FieldOutput) on successful resolution, containing the resolved output values.
  • Err(Error) if an error occurs during the resolution process, encapsulating details about what went wrong. This will prevent resolving of the field.

The FieldOutput type has multiple response values, which can be either successful or an error result.

Implementors§