Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,18 @@ At the crate root:
* `ShutdownKind` → `ShutdownSource`
* `ApolloRouter` → `RouterHttpServer`

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

* `router_service` → `supergraph_service`
* `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:
Additionally, the "router stage" is now known as "supergraph stage".
In pseudo-syntax, `use`’ing the old names:

```rust
mod router {
mod supergraph {
use apollo_router::services::RouterRequest as Request;
use apollo_router::services::RouterResponse as Response;
type BoxService = tower::util::BoxService<Request, Response, BoxError>;
Expand Down
8 changes: 4 additions & 4 deletions apollo-router-benchmarks/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use apollo_router::plugin::Plugin;
use apollo_router::plugin::PluginInit;
use apollo_router::plugin::test::MockSubgraph;
use apollo_router::stages::router;
use apollo_router::stages::supergraph;
use apollo_router::stages::subgraph;
use apollo_router::TestHarness;
use apollo_router::graphql::Response;
Expand All @@ -21,14 +21,14 @@ static EXPECTED_RESPONSE: Lazy<Response> = Lazy::new(|| {
static QUERY: &str = r#"query TopProducts($first: Int) { topProducts(first: $first) { upc name reviews { id product { name } author { id name } } } }"#;

pub async fn basic_composition_benchmark(
mut router_service: router::BoxCloneService,
mut supergraph_service: supergraph::BoxCloneService,
) {
let request = router::Request::fake_builder()
let request = supergraph::Request::fake_builder()
.query(QUERY.to_string())
.variable("first", 2usize)
.build().expect("expecting valid request");

let response = router_service
let response = supergraph_service
.ready()
.await
.unwrap()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use apollo_router::plugin::Plugin;
use apollo_router::plugin::PluginInit;
use apollo_router::register_plugin;
use apollo_router::stages::router;
use apollo_router::stages::supergraph;
{{#if type_basic}}
use apollo_router::stages::execution;
use apollo_router::stages::query_planner;
Expand Down Expand Up @@ -47,10 +47,10 @@ impl Plugin for {{pascal_name}} {
}

// Delete this function if you are not customizing it.
fn router_service(
fn supergraph_service(
&self,
service: router::BoxService,
) -> router::BoxService {
service: supergraph::BoxService,
) -> supergraph::BoxService {
// Always use service builder to compose your plugins.
// It provides off the shelf building blocks for your plugin.
//
Expand All @@ -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 Expand Up @@ -99,13 +99,13 @@ impl Plugin for {{pascal_name}} {
Ok({{pascal_name}} { configuration: init.config })
}

fn router_service(
fn supergraph_service(
&self,
service: router::BoxService,
) -> router::BoxService {
service: supergraph::BoxService,
) -> supergraph::BoxService {

ServiceBuilder::new()
.checkpoint_async(|request : router::Request| async {
.checkpoint_async(|request : supergraph::Request| async {
// Do some async call here to auth, and decide if to continue or not.
Ok(ControlFlow::Continue(request))
})
Expand All @@ -126,10 +126,10 @@ impl Plugin for {{pascal_name}} {
Ok({{pascal_name}} { configuration: init.config })
}

fn router_service(
fn supergraph_service(
&self,
service: router::BoxService,
) -> router::BoxService {
service: supergraph::BoxService,
) -> supergraph::BoxService {

ServiceBuilder::new()
.instrument(|_request| {
Expand All @@ -155,7 +155,7 @@ register_plugin!("{{project_name}}", "{{snake_name}}", {{pascal_name}});
#[cfg(test)]
mod tests {
use apollo_router::TestHarness;
use apollo_router::stages::router;
use apollo_router::stages::supergraph;
use tower::BoxError;
use tower::ServiceExt;

Expand All @@ -173,7 +173,7 @@ mod tests {
.build()
.await
.unwrap();
let request = router::Request::canned_builder().build().unwrap();
let request = supergraph::Request::canned_builder().build().unwrap();
let mut streamed_response = test_harness.oneshot(request).await?;

let first_response = streamed_response
Expand Down
Loading