Skip to content

Commit

Permalink
remove unused test mock + rework visibility according to the new clip…
Browse files Browse the repository at this point in the history
…py warnings
  • Loading branch information
o0Ignition0o committed Aug 19, 2022
1 parent 895714b commit 5b5612a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
1 change: 0 additions & 1 deletion apollo-router/src/plugin/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::sync::Arc;

pub use mock::subgraph::MockSubgraph;
pub use service::MockExecutionService;
pub use service::MockQueryPlannerService;
pub use service::MockSubgraphService;
pub use service::MockSupergraphService;
use tower::util::BoxService;
Expand Down
3 changes: 0 additions & 3 deletions apollo-router/src/plugin/test/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

use crate::ExecutionRequest;
use crate::ExecutionResponse;
use crate::QueryPlannerRequest;
use crate::QueryPlannerResponse;
use crate::SubgraphRequest;
use crate::SubgraphResponse;
use crate::SupergraphRequest;
Expand Down Expand Up @@ -46,6 +44,5 @@ macro_rules! mock_service {
}

mock_service!(Supergraph, SupergraphRequest, SupergraphResponse);
mock_service!(QueryPlanner, QueryPlannerRequest, QueryPlannerResponse);
mock_service!(Execution, ExecutionRequest, ExecutionResponse);
mock_service!(Subgraph, SubgraphRequest, SubgraphResponse);
40 changes: 7 additions & 33 deletions apollo-router/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,18 @@ impl SupergraphResponse {
assert_impl_all!(QueryPlannerRequest: Send);
/// [`Context`] for the request.
#[derive(Clone, Debug)]
pub struct QueryPlannerRequest {
pub query: String,
pub operation_name: Option<String>,
pub context: Context,
pub(crate) struct QueryPlannerRequest {
pub(crate) query: String,
pub(crate) operation_name: Option<String>,
pub(crate) context: Context,
}

#[buildstructor::buildstructor]
impl QueryPlannerRequest {
/// This is the constructor (or builder) to use when constructing a real QueryPlannerRequest.
///
/// Required parameters are required in non-testing code to create a QueryPlannerRequest.
#[builder(visibility = "pub")]
#[builder]
pub(crate) fn new(
query: String,
operation_name: Option<String>,
Expand All @@ -355,9 +355,9 @@ impl QueryPlannerRequest {

assert_impl_all!(QueryPlannerResponse: Send);
/// [`Context`] and [`QueryPlan`] for the response.
pub struct QueryPlannerResponse {
pub(crate) struct QueryPlannerResponse {
pub(crate) content: QueryPlannerContent,
pub context: Context,
pub(crate) context: Context,
}

/// Query, QueryPlan and Introspection data.
Expand All @@ -382,32 +382,6 @@ impl QueryPlannerResponse {
pub(crate) fn new(content: QueryPlannerContent, context: Context) -> QueryPlannerResponse {
Self { content, context }
}

/// This is the constructor (or builder) to use when constructing a QueryPlannerResponse that represents a global error.
/// It has no path and no response data.
/// This is useful for things such as authentication errors.
#[allow(unused_variables)]
#[builder(visibility = "pub")]
fn error_new(
errors: Vec<Error>,
status_code: Option<StatusCode>,
headers: MultiMap<IntoHeaderName, IntoHeaderValue>,
context: Context,
) -> Result<QueryPlannerResponse, BoxError> {
tracing::warn!("no way to propagate error response from QueryPlanner");
Ok(QueryPlannerResponse::new(
QueryPlannerContent::Plan {
plan: Arc::new(QueryPlan::fake_builder().build()),
query: Arc::new(Query::default()),
},
context,
))
}

/// Get a reference of the query plan
pub fn query_plan(&self) -> &QueryPlannerContent {
&self.content
}
}

assert_impl_all!(SubgraphRequest: Send);
Expand Down

0 comments on commit 5b5612a

Please sign in to comment.