#![allow(missing_docs)] use std::sync::Arc;
use serde_json_bytes::Value;
use static_assertions::assert_impl_all;
use tokio::sync::mpsc;
use tower::BoxError;
use crate::graphql;
use crate::Context;
pub(crate) mod service;
pub type BoxService = tower::util::BoxService<Request, Response, BoxError>;
pub type BoxCloneService = tower::util::BoxCloneService<Request, Response, BoxError>;
pub type ServiceResult = Result<Response, BoxError>;
use super::SubscriptionTaskParams;
pub use crate::query_planner::QueryPlan;
assert_impl_all!(Request: Send);
#[non_exhaustive]
pub struct Request {
pub supergraph_request: http::Request<graphql::Request>,
pub query_plan: Arc<QueryPlan>,
pub context: Context,
pub(crate) source_stream_value: Option<Value>,
pub(crate) subscription_tx: Option<mpsc::Sender<SubscriptionTaskParams>>,
}
#[buildstructor::buildstructor]
impl Request {
#[builder(visibility = "pub")]
fn new(
supergraph_request: http::Request<graphql::Request>,
query_plan: Arc<QueryPlan>,
context: Context,
source_stream_value: Option<Value>,
subscription_tx: Option<mpsc::Sender<SubscriptionTaskParams>>,
) -> Request {
Self {
supergraph_request,
query_plan,
context,
source_stream_value,
subscription_tx,
}
}
#[builder(visibility = "pub(crate)")]
#[allow(clippy::needless_lifetimes)] async fn internal_new(
supergraph_request: http::Request<graphql::Request>,
query_plan: Arc<QueryPlan>,
context: Context,
source_stream_value: Option<Value>,
subscription_tx: Option<mpsc::Sender<SubscriptionTaskParams>>,
) -> Request {
Self {
supergraph_request,
query_plan,
context,
source_stream_value,
subscription_tx,
}
}
#[builder(visibility = "pub")]
fn fake_new(
supergraph_request: Option<http::Request<graphql::Request>>,
query_plan: Option<QueryPlan>,
context: Option<Context>,
source_stream_value: Option<Value>,
subscription_tx: Option<mpsc::Sender<SubscriptionTaskParams>>,
) -> Request {
Request::new(
supergraph_request.unwrap_or_default(),
Arc::new(query_plan.unwrap_or_else(|| QueryPlan::fake_builder().build())),
context.unwrap_or_default(),
source_stream_value,
subscription_tx,
)
}
}
pub type Response = super::supergraph::Response;