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,
impl<'r, 'a, CtxT, S> Executor<'r, 'a, CtxT, S>where
S: ScalarValue,
Sourcepub async fn resolve_into_stream<'i, 'v, 'res, T>(
&'r self,
info: &'i T::TypeInfo,
value: &'v T,
) -> Value<ValuesStream<'res, S>>
pub async fn resolve_into_stream<'i, 'v, 'res, T>( &'r self, info: &'i T::TypeInfo, value: &'v T, ) -> Value<ValuesStream<'res, S>>
Resolve a single arbitrary value into a stream of Value
s.
If a field fails to resolve, pushes error to Executor
and returns Value::Null
.
Sourcepub async fn subscribe<'s, 't, 'res, T>(
&'r self,
info: &'t T::TypeInfo,
value: &'t T,
) -> Result<Value<ValuesStream<'res, S>>, FieldError<S>>
pub async fn subscribe<'s, 't, 'res, T>( &'r self, info: &'t T::TypeInfo, value: &'t T, ) -> Result<Value<ValuesStream<'res, S>>, FieldError<S>>
Resolve a single arbitrary value into a stream of Value
s.
Calls resolve_into_stream
on T
.
Sourcepub fn resolve_with_ctx<NewCtxT, T>(
&self,
info: &T::TypeInfo,
value: &T,
) -> ExecutionResult<S>
pub fn resolve_with_ctx<NewCtxT, T>( &self, info: &T::TypeInfo, value: &T, ) -> ExecutionResult<S>
Resolve a single arbitrary value, mapping the context to a new type
Sourcepub fn resolve<T>(&self, info: &T::TypeInfo, value: &T) -> ExecutionResult<S>where
T: GraphQLValue<S, Context = CtxT> + ?Sized,
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
Sourcepub async fn resolve_async<T>(
&self,
info: &T::TypeInfo,
value: &T,
) -> ExecutionResult<S>
pub async fn resolve_async<T>( &self, info: &T::TypeInfo, value: &T, ) -> ExecutionResult<S>
Resolve a single arbitrary value into an ExecutionResult
Sourcepub 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,
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
Sourcepub fn resolve_into_value<T>(&self, info: &T::TypeInfo, value: &T) -> Value<S>where
T: GraphQLValue<S, Context = CtxT>,
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.
Sourcepub async fn resolve_into_value_async<T>(
&self,
info: &T::TypeInfo,
value: &T,
) -> Value<S>
pub async fn resolve_into_value_async<T>( &self, info: &T::TypeInfo, value: &T, ) -> Value<S>
Resolve a single arbitrary value into a return value
If the field fails to resolve, null
will be returned.
Sourcepub fn replaced_context<'b, NewCtxT>(
&'b self,
ctx: &'b NewCtxT,
) -> Executor<'b, 'b, NewCtxT, S>
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.
Sourcepub fn context(&self) -> &'r CtxT
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.
Sourcepub fn schema(&self) -> &'a SchemaType<'_, S>
pub fn schema(&self) -> &'a SchemaType<'_, S>
The currently executing schema
Sourcepub fn location(&self) -> &SourcePosition
pub fn location(&self) -> &SourcePosition
The current location of the executor
Sourcepub fn push_error(&self, error: FieldError<S>)
pub fn push_error(&self, error: FieldError<S>)
Add an error to the execution engine at the current executor location
Sourcepub fn push_error_at(&self, error: FieldError<S>, location: SourcePosition)
pub fn push_error_at(&self, error: FieldError<S>, location: SourcePosition)
Add an error to the execution engine at a specific location
Sourcepub fn new_error(&self, error: FieldError<S>) -> ExecutionError<S>
pub fn new_error(&self, error: FieldError<S>) -> ExecutionError<S>
Returns new ExecutionError
at current location
Sourcepub fn look_ahead(&'a self) -> LookAheadSelection<'a, S>
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.
Sourcepub fn as_owned_executor(&self) -> OwnedExecutor<'a, CtxT, S>
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.