use std::future::Future;
use fraiseql_error::Result;
use super::{DatabaseAdapter, RelayCursor, RelayPageResult};
use crate::{
types::{ReadRouting, sql_hints::OrderByClause},
where_clause::WhereClause,
};
pub trait RelayDatabaseAdapter: DatabaseAdapter {
fn execute_relay_page<'a>(
&'a self,
view: &'a str,
cursor_column: &'a str,
after: Option<RelayCursor>,
before: Option<RelayCursor>,
limit: u32,
forward: bool,
where_clause: Option<&'a WhereClause>,
order_by: Option<&'a [OrderByClause]>,
include_total_count: bool,
) -> impl Future<Output = Result<RelayPageResult>> + Send + 'a;
#[allow(clippy::too_many_arguments)] fn execute_relay_page_with_session<'a>(
&'a self,
view: &'a str,
cursor_column: &'a str,
after: Option<RelayCursor>,
before: Option<RelayCursor>,
limit: u32,
forward: bool,
where_clause: Option<&'a WhereClause>,
order_by: Option<&'a [OrderByClause]>,
include_total_count: bool,
session_vars: &'a [(&'a str, &'a str)],
_routing: ReadRouting,
_decimals: Option<&'a super::DecimalShape>,
) -> impl Future<Output = Result<RelayPageResult>> + Send + 'a {
async move {
super::refuse_session_variables(self, session_vars)?;
self.execute_relay_page(
view,
cursor_column,
after,
before,
limit,
forward,
where_clause,
order_by,
include_total_count,
)
.await
}
}
}