pub trait QueryFunctionResolver: Send + Sync {
// Required method
fn resolve<'a>(
&'a self,
request: QueryFunctionRequest<'a>,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'a>>;
}Expand description
Answers a function-backed root query field.
Registered on RuntimeConfig via
with_query_function_resolver,
parallel to
with_before_mutation_gate.
§The return value is the field’s data, not a response
For a single-item field: the entity document, or null. For a list field: an
array of them. The engine projects the selection set over it, so the guest
returns whatever the type declares and never a GraphQL envelope — which also
means a guest cannot invent a field the schema does not declare, or return one
the caller’s scopes deny.
Required Methods§
Sourcefn resolve<'a>(
&'a self,
request: QueryFunctionRequest<'a>,
) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'a>>
fn resolve<'a>( &'a self, request: QueryFunctionRequest<'a>, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'a>>
Invoke the function that backs this field.
§Errors
Any error refuses the field. A resolver is expected to map its own failures — a missing module, a guest exception, a timeout — to an error that names the field, because by the time the engine sees it the only other thing it could say is “the query failed”.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".