stellation_bridge/resolvers.rs
1//! Bridge resolvers.
2
3use async_trait::async_trait;
4
5use crate::routines::{BridgedMutation, BridgedQuery, MutationResult, QueryResult};
6
7/// The resolver of a bridge query.
8///
9/// This type is required to be implemented for `LocalLink`.
10/// Please refer to the crate implementation for more information.
11#[async_trait(?Send)]
12pub trait QueryResolver: BridgedQuery {
13 /// The context type.
14 ///
15 /// This type needs to match the `CTX` type parameter of the bridge it is added.
16 type Context: 'static;
17
18 /// Resolves the current query.
19 async fn resolve(meta: &Self::Context, input: &Self::Input) -> QueryResult<Self>;
20}
21
22/// The resolver of a bridge mutation.
23///
24/// This type is required to be implemented for `LocalLink`.
25/// Please refer to the crate implementation for more information.
26#[async_trait(?Send)]
27pub trait MutationResolver: BridgedMutation {
28 /// The context type.
29 ///
30 /// This type needs to match the `CTX` type parameter of the bridge it is added.
31 type Context: 'static;
32
33 /// Resolves the current mutation.
34 async fn resolve(meta: &Self::Context, input: &Self::Input) -> MutationResult<Self>;
35}