pub trait GraphQLField: Send + Sync {
// Required method
fn resolve<'life0, 'async_trait>(
&'life0 self,
req: FieldRequest,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
富 resolver trait:可访问字段参数与嵌套 selection(经
GraphQLSchema::query_field / GraphQLSchema::mutation_field 注册)。
async fn in trait 非 dyn-compatible,故用 #async_trait 换取对象安全
(可存入 FieldHandler::Rich 的 Arc<dyn GraphQLField>)。
Required Methods§
fn resolve<'life0, 'async_trait>(
&'life0 self,
req: FieldRequest,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".