juniper::executor

Struct Executor

Source
pub struct Executor<'r, 'a, CtxT, S = DefaultScalarValue>
where CtxT: 'a, S: 'a,
{ /* private fields */ }
Expand description

Query execution engine

The executor helps drive the query execution in a schema. It keeps track of the current field stack, context, variables, and errors.

Implementations§

Source§

impl<'r, 'a, CtxT, S> Executor<'r, 'a, CtxT, S>
where S: ScalarValue,

Source

pub async fn resolve_into_stream<'i, 'v, 'res, T>( &'r self, info: &'i T::TypeInfo, value: &'v T, ) -> Value<ValuesStream<'res, S>>
where T: GraphQLSubscriptionValue<S, Context = CtxT> + ?Sized, T::TypeInfo: Sync, CtxT: Sync, S: Send + Sync, 'i: 'res, 'v: 'res, 'a: 'res,

Resolve a single arbitrary value into a stream of Values. If a field fails to resolve, pushes error to Executor and returns Value::Null.

Source

pub async fn subscribe<'s, 't, 'res, T>( &'r self, info: &'t T::TypeInfo, value: &'t T, ) -> Result<Value<ValuesStream<'res, S>>, FieldError<S>>
where T: GraphQLSubscriptionValue<S, Context = CtxT> + ?Sized, T::TypeInfo: Sync, CtxT: Sync, S: Send + Sync, 't: 'res, 'a: 'res,

Resolve a single arbitrary value into a stream of Values. Calls resolve_into_stream on T.

Source

pub fn resolve_with_ctx<NewCtxT, T>( &self, info: &T::TypeInfo, value: &T, ) -> ExecutionResult<S>
where NewCtxT: FromContext<CtxT>, T: GraphQLValue<S, Context = NewCtxT> + ?Sized,

Resolve a single arbitrary value, mapping the context to a new type

Source

pub fn resolve<T>(&self, info: &T::TypeInfo, value: &T) -> ExecutionResult<S>
where T: GraphQLValue<S, Context = CtxT> + ?Sized,

Resolve a single arbitrary value into an ExecutionResult

Source

pub async fn resolve_async<T>( &self, info: &T::TypeInfo, value: &T, ) -> ExecutionResult<S>
where T: GraphQLValueAsync<S, Context = CtxT> + ?Sized, T::TypeInfo: Sync, CtxT: Sync, S: Send + Sync,

Resolve a single arbitrary value into an ExecutionResult

Source

pub async fn resolve_with_ctx_async<NewCtxT, T>( &self, info: &T::TypeInfo, value: &T, ) -> ExecutionResult<S>
where T: GraphQLValueAsync<S, Context = NewCtxT> + ?Sized, T::TypeInfo: Sync, NewCtxT: FromContext<CtxT> + Sync, S: Send + Sync,

Resolve a single arbitrary value, mapping the context to a new type

Source

pub fn resolve_into_value<T>(&self, info: &T::TypeInfo, value: &T) -> Value<S>
where T: GraphQLValue<S, Context = CtxT>,

Resolve a single arbitrary value into a return value

If the field fails to resolve, null will be returned.

Source

pub async fn resolve_into_value_async<T>( &self, info: &T::TypeInfo, value: &T, ) -> Value<S>
where T: GraphQLValueAsync<S, Context = CtxT> + ?Sized, T::TypeInfo: Sync, CtxT: Sync, S: Send + Sync,

Resolve a single arbitrary value into a return value

If the field fails to resolve, null will be returned.

Source

pub fn replaced_context<'b, NewCtxT>( &'b self, ctx: &'b NewCtxT, ) -> Executor<'b, 'b, NewCtxT, S>

Derive a new executor by replacing the context

This can be used to connect different types, e.g. from different Rust libraries, that require different context types.

Source

pub fn context(&self) -> &'r CtxT

Access the current context

You usually provide the context when calling the top-level execute function, or using the context factory.

Source

pub fn schema(&self) -> &'a SchemaType<'_, S>

The currently executing schema

Source

pub fn location(&self) -> &SourcePosition

The current location of the executor

Source

pub fn push_error(&self, error: FieldError<S>)

Add an error to the execution engine at the current executor location

Source

pub fn push_error_at(&self, error: FieldError<S>, location: SourcePosition)

Add an error to the execution engine at a specific location

Source

pub fn new_error(&self, error: FieldError<S>) -> ExecutionError<S>

Returns new ExecutionError at current location

Source

pub fn look_ahead(&'a self) -> LookAheadSelection<'a, S>

Construct a lookahead selection for the current selection.

This allows seeing the whole selection and perform operations affecting the children.

Source

pub fn as_owned_executor(&self) -> OwnedExecutor<'a, CtxT, S>

Create new OwnedExecutor and clone all current data (except for errors) there

New empty vector is created for errors because existing errors won’t be needed to be accessed by user in OwnedExecutor as existing errors will be returned in execute_query/execute_mutation/resolve_into_stream/etc.

Auto Trait Implementations§

§

impl<'r, 'a, CtxT, S> Freeze for Executor<'r, 'a, CtxT, S>

§

impl<'r, 'a, CtxT, S> RefUnwindSafe for Executor<'r, 'a, CtxT, S>
where CtxT: RefUnwindSafe, S: RefUnwindSafe,

§

impl<'r, 'a, CtxT, S> Send for Executor<'r, 'a, CtxT, S>
where CtxT: Sync, S: Sync + Send,

§

impl<'r, 'a, CtxT, S> Sync for Executor<'r, 'a, CtxT, S>
where CtxT: Sync, S: Sync + Send,

§

impl<'r, 'a, CtxT, S> Unpin for Executor<'r, 'a, CtxT, S>

§

impl<'r, 'a, CtxT, S> UnwindSafe for Executor<'r, 'a, CtxT, S>
where CtxT: RefUnwindSafe, S: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.