Skip to content

Commit

Permalink
Rename Plugin::query_planning_service to query_planner_service
Browse files Browse the repository at this point in the history
Part of #1138
  • Loading branch information
SimonSapin committed Aug 17, 2022
1 parent b4ebe6b commit 569d24c
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 19 deletions.
4 changes: 4 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ At the crate root:
* `ShutdownKind` → `ShutdownSource`
* `ApolloRouter` → `RouterHttpServer`

In the `apollo_router::plugin::Plugin` trait:

* `query_planning_service` → `query_planner_service`

A new `apollo_router::stages` module replaces `apollo_router::services` in the public API,
reexporting its items and adding `BoxService` and `BoxCloneService` type aliases.
In pseudo-syntax:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Plugin for {{pascal_name}} {
}

// Delete this function if you are not customizing it.
fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down
12 changes: 6 additions & 6 deletions apollo-router/src/plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ pub trait Plugin: Send + Sync + 'static + Sized {
}

/// This service handles generating the query plan for each incoming request.
/// Define `query_planning_service` if your customization needs to interact with query planning functionality (for example, to log query plan details).
/// Define `query_planner_service` if your customization needs to interact with query planning functionality (for example, to log query plan details).
///
/// Query planning uses a cache that will store the result of the query planner and query planning plugins execution, so if the same query is
/// performed twice, the query planner plugins will onyl see it once. The caching key contains the query and operation name. If modifications
/// must be performed on the query, they should be done in router service plugins.
fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down Expand Up @@ -233,12 +233,12 @@ pub(crate) trait DynPlugin: Send + Sync + 'static {
fn router_service(&self, service: router::BoxService) -> router::BoxService;

/// This service handles generating the query plan for each incoming request.
/// Define `query_planning_service` if your customization needs to interact with query planning functionality (for example, to log query plan details).
/// Define `query_planner_service` if your customization needs to interact with query planning functionality (for example, to log query plan details).
///
/// Query planning uses a cache that will store the result of the query planner and query planning plugins execution, so if the same query is
/// performed twice, the query planner plugins will onyl see it once. The caching key contains the query and operation name. If modifications
/// must be performed on the query, they should be done in router service plugins.
fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService;
Expand Down Expand Up @@ -279,11 +279,11 @@ where
self.router_service(service)
}

fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
self.query_planning_service(service)
self.query_planner_service(service)
}

fn execution_service(&self, service: execution::BoxService) -> execution::BoxService {
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/plugin/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::Arc;

pub use mock::subgraph::MockSubgraph;
pub use service::MockExecutionService;
pub use service::MockQueryPlanningService;
pub use service::MockQueryPlannerService;
pub use service::MockRouterService;
pub use service::MockSubgraphService;
use tower::util::BoxService;
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/plugin/test/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ macro_rules! mock_service {
}

mock_service!(Router, RouterRequest, RouterResponse);
mock_service!(QueryPlanning, QueryPlannerRequest, QueryPlannerResponse);
mock_service!(QueryPlanner, QueryPlannerRequest, QueryPlannerResponse);
mock_service!(Execution, ExecutionRequest, ExecutionResponse);
mock_service!(Subgraph, SubgraphRequest, SubgraphResponse);
2 changes: 1 addition & 1 deletion apollo-router/src/plugins/expose_query_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Plugin for ExposeQueryPlan {
})
}

fn query_planning_service(
fn query_planner_service(
&self,
service: BoxService<QueryPlannerRequest, QueryPlannerResponse, BoxError>,
) -> BoxService<QueryPlannerRequest, QueryPlannerResponse, BoxError> {
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/plugins/rhai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl Plugin for Rhai {
shared_service.take_unwrap()
}

fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/plugins/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Plugin for Telemetry {
.boxed()
}

fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/plugins/traffic_shaping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl Plugin for TrafficShaping {
}
}

fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/services/router_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl PluggableRouterServiceBuilder {
.iter_mut()
.rev()
.fold(bridge_query_planner.boxed(), |acc, (_, e)| {
e.query_planning_service(acc)
e.query_planner_service(acc)
}),
DEFAULT_BUFFER_SIZE,
),
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/src/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'a> TestHarness<'a> {
self.extra_plugin(RouterServicePlugin(callback))
}

/// Adds an ad-hoc plugin that has [`Plugin::query_planning_service`] implemented with `callback`.
/// Adds an ad-hoc plugin that has [`Plugin::query_planner_service`] implemented with `callback`.
pub fn extra_query_planner_plugin(
self,
callback: impl Fn(query_planner::BoxService) -> query_planner::BoxService
Expand Down Expand Up @@ -248,7 +248,7 @@ where
unreachable!()
}

fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/customizations/native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Plugin for HelloWorld {
service
}

fn query_planning_service(
fn query_planner_service(
&mut self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down
2 changes: 1 addition & 1 deletion docs/source/customizations/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Each Apollo Router service has a corresponding function that a customization can
| Service | Function | Description |
|---------|----------|-------------|
| `RouterService` | `router_service` | <p>This service runs at the very beginning and very end of the request lifecycle.</p><p>Define `router_service` if your customization needs to interact at the earliest or latest point possible. For example, this is a good opportunity to perform JWT verification before allowing a request to proceed further. </p>|
| `QueryPlannerService` | `query_planning_service` | <p>This service handles generating the query plan for each incoming request. </p><p>Define `query_planning_service` if your customization needs to interact with query planning functionality (for example, to log query plan details).</p> |
| `QueryPlannerService` | `query_planner_service` | <p>This service handles generating the query plan for each incoming request. </p><p>Define `query_planner_service` if your customization needs to interact with query planning functionality (for example, to log query plan details).</p> |
| `ExecutionService` | `execution_service` | <p>This service handles initiating the execution of a query plan after it's been generated.</p><p>Define `execution_service` if your customization includes logic to govern execution (for example, if you want to block a particular query based on a policy decision).</p>|
| `SubgraphService` | `subgraph_service` | This service handles communication between the Apollo Router and your subgraphs. Define `subgraph_service` to configure this communication (for example, to dynamically add headers to pass to a subgraph). |

Expand Down
2 changes: 1 addition & 1 deletion examples/hello-world/src/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Plugin for HelloWorld {
.boxed()
}

fn query_planning_service(
fn query_planner_service(
&self,
service: query_planner::BoxService,
) -> query_planner::BoxService {
Expand Down

0 comments on commit 569d24c

Please sign in to comment.