Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api 1.0 phase 1 #1274

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5004c66
Remove apollo_router::prelude::graphql reexports (#1216)
SimonSapin Jun 10, 2022
78f4f47
Remove typed builder. All builders use buildstructor. (#1218)
BrynCooke Jun 13, 2022
e3968b9
Merge branch 'main' into api-1.0
garypen Jun 13, 2022
a141aa4
checkpoint_async() shouldn't require a boxed argument (#1226)
garypen Jun 14, 2022
315ea78
merge with main
garypen Jun 14, 2022
5864087
Fix up the merge
garypen Jun 14, 2022
ebe7a70
Entry point improvements (#1227)
BrynCooke Jun 14, 2022
6b5151e
Rename FederatedServerError to `ApolloRouterError` (#1234)
BrynCooke Jun 14, 2022
7680d99
Remove `main_rt` (#1239)
BrynCooke Jun 14, 2022
1f5ae84
Remove public glob reexports from the crate top-level (#1242)
SimonSapin Jun 14, 2022
26e57d0
Merge branch 'main' into api-1.0
Jun 15, 2022
54b7287
add support for modifying request variables from a plugin (#1257)
garypen Jun 15, 2022
22e94ce
Make Executable::builder() async (#1263)
BrynCooke Jun 16, 2022
9d1af01
Fix some links in doc-comments. (#1271)
SimonSapin Jun 16, 2022
84ed475
Fix config schema test after doc change (#1272)
SimonSapin Jun 16, 2022
b48de44
Change unreachable `pub` items to be private to the create (#1273)
SimonSapin Jun 16, 2022
861239e
Flatten the public API of apollo_router::plugin (#1267)
SimonSapin Jun 16, 2022
9eec17f
Merge branch 'main' into api-1.0
garypen Jun 16, 2022
1a3b506
Merge branch 'api-1.0' of github.com:apollographql/router into api-1.0
garypen Jun 16, 2022
d9e7036
add missing snapshot from merge
garypen Jun 16, 2022
508bec8
merge with simon's last PR which arrived mid merge
garypen Jun 16, 2022
148652d
refactor query planner (#1233)
Jun 17, 2022
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
14 changes: 1 addition & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 30 additions & 100 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,97 +27,43 @@ By [@USERNAME](https://github.com/USERNAME) in https://github.com/apollographql/
# [0.9.5] (unreleased) - 2022-mm-dd
## ❗ BREAKING ❗

### Rename `experimental.traffic_shaping` to `apollo.traffic_shaping` [PR #1229](https://github.com/apollographql/router/pull/1229)
You will need to update your YAML configuration file to use the correct name for `traffic_shaping` plugin.

```diff
- plugins:
- experimental.traffic_shaping:
- variables_deduplication: true # Enable the variables deduplication optimization
- all:
- query_deduplication: true # Enable query deduplication for all subgraphs.
- subgraphs:
- products:
- query_deduplication: false # Disable query deduplication for products.
+ traffic_shaping:
+ variables_deduplication: true # Enable the variables deduplication optimization
+ all:
+ query_deduplication: true # Enable query deduplication for all subgraphs.
+ subgraphs:
+ products:
+ query_deduplication: false # Disable query deduplication for products.
```

### Rhai plugin `request.sub_headers` renamed to `request.subgraph.headers` [PR #1261](https://github.com/apollographql/router/pull/1261)
### Entry point improvements ([PR #1227](https://github.com/apollographql/router/pull/1227)) ([PR #1234](https://github.com/apollographql/router/pull/1234)) ([PR #1239](https://github.com/apollographql/router/pull/1239)) ([PR #1263](https://github.com/apollographql/router/pull/1263))

Rhai scripts previously supported the `request.sub_headers` attribute so that subgraph request headers could be
accessed. This is now replaced with an extended interface for subgraph requests:
The interfaces around the entry point have been improved for naming consistency and to enable reuse when customization is required.

```
request.subgraph.headers
request.subgraph.body.query
request.subgraph.body.operation_name
request.subgraph.body.variables
request.subgraph.body.extensions
request.subgraph.uri.host
request.subgraph.uri.path
Most users will continue to use:
```rust
apollo_router::main()
```

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/1261

## 🚀 Features
However, if you want to specify extra customization to configuration/schema/shutdown then you may use `Executable::builder()` to override behavior.

### Add support of compression [PR #1229](https://github.com/apollographql/router/pull/1229)
Add support of request and response compression for the router and all subgraphs. The router is now able to handle `Content-Encoding` and `Accept-Encoding` headers properly. Supported algorithms are `gzip`, `br`, `deflate`.
You can also enable compression on subgraphs requests and responses by updating the `traffic_shaping` configuration:

```yaml
traffic_shaping:
all:
compression: br # Enable brotli compression for all subgraphs
subgraphs:
products:
compression: gzip # Enable gzip compression only for subgraph products
```rust
use apollo_router::Executable;
Executable::builder()
.router_builder_fn(|configuration, schema| ...) // Optional
.start().await?
```

By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/1229
Migration tips:
* Calls to `ApolloRouterBuilder::default()` should be migrated to `ApolloRouter::builder`.
* `FederatedServerHandle` has been renamed to `ApolloRouterHandle`.
* The ability to supply your own `RouterServiceFactory` has been removed.
* `StateListener`. This made the internal state machine unnecessarily complex. `listen_address()` remains on `ApolloRouterHandle`.
* `FederatedServerHandle::shutdown()` has been removed. Instead, dropping `ApolloRouterHandle` will cause the router to shutdown.
* `FederatedServerHandle::ready()` has been renamed to `FederatedServerHandle::listen_address()`, it will return the address when the router is ready to serve requests.
* `FederatedServerError` has been renamed to `ApolloRouterError`.
* `main_rt` should be migrated to `Executable::builder()`

By [@bryncooke](https://github.com/bryncooke) in https://github.com/apollographql/router/pull/1227 https://github.com/apollographql/router/pull/1234 https://github.com/apollographql/router/pull/1239 https://github.com/apollographql/router/pull/1263

### Add support of multiple uplink URLs [PR #1210](https://github.com/apollographql/router/pull/1210)
Add support of multiple uplink URLs with a comma-separated list in `APOLLO_UPLINK_ENDPOINTS` and for `--apollo-uplink-endpoints`
## 🚀 Features ( :rocket: )

Example:
```bash
export APOLLO_UPLINK_ENDPOINTS="https://aws.uplink.api.apollographql.com/, https://uplink.api.apollographql.com/"
```
### Add support for modifying variables from a plugin. [PR #1257](https://github.com/apollographql/router/pull/1257)

By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/1210

### Add support for adding extra enviromental variables and volumes to helm chart [PR #1245](https://github.com/apollographql/router/pull/1245)

The following example will allow you to mount your supergraph.yaml into the helm deployment using a configmap with a key of supergraph.yaml. Using [Kustomize](https://kustomize.io/) to generate your configmap from your supergraph.yaml is suggested.

Example:
```yaml
extraEnvVars:
- name: APOLLO_ROUTER_SUPERGRAPH_PATH
value: /etc/apollo/supergraph.yaml
# sets router log level to debug
- name: APOLLO_ROUTER_LOG
value: debug
extraEnvVarsCM: ''
extraEnvVarsSecret: ''

extraVolumes:
- name: supergraph-volume
configMap:
name: some-configmap
extraVolumeMounts:
- name: supergraph-volume
mountPath: /etc/apollo
```
Previously, it was not possible to modify variables in a `Request` from a plugin. This is now supported in both Rust and Rhai plugins.

By [@LockedThread](https://github.com/LockedThread) in https://github.com/apollographql/router/pull/1245
By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/1257

## 🐛 Fixes

Expand All @@ -137,26 +83,10 @@ resulting in some introspection queries not working.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1240

### Create the ExecutionResponse after the primary response was generated ([PR #1260](https://github.com/apollographql/router/pull/1260))

The `@defer` preliminary work has a surprising side effect: when using methods like `RouterResponse::map_response`, they are
executed before the subgraph responses are received, because they work on the stream of responses.
This PR goes back to the previous behaviour by awaiting the primary response before creating the ExecutionResponse.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1260

### Use the API schema to generate selections ([PR #1255](https://github.com/apollographql/router/pull/1255))

When parsing the schema to generate selections for response formatting, we should use the API schema instead of the supergraph schema.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/1255

## 🛠 Maintenance
## 📚 Documentation

### Update README link to the configuration file ([PR #1208](https://github.com/apollographql/router/pull/1208))

As the structure of the documentation has changed, the link should point to the `YAML config file` section of the overview.
## 🛠 Maintenance ( :hammer_and_wrench: )

By [@gscheibel](https://github.com/gscheibel in https://github.com/apollographql/router/pull/1208
### Remove typed-builder ([PR #1218](https://github.com/apollographql/router/pull/1218))
Migrate all typed-builders code to buildstructor
By [@bryncooke](https://github.com/bryncooke) in https://github.com/apollographql/router/pull/1218
## 📚 Documentation ( :books: )

2 changes: 1 addition & 1 deletion apollo-router-benchmarks/src/shared.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// this file is shared between the tests and benchmarks, using
// include!() instead of as a pub module, so it is only compiled
// in dev mode
use apollo_router::plugin::utils::test::mock::subgraph::MockSubgraph;
use apollo_router::plugin::test::MockSubgraph;
use apollo_router::{
PluggableRouterServiceBuilder, ResponseBody, RouterRequest, RouterResponse, Schema,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use apollo_router::{
register_plugin, ResponseBody, RouterRequest, RouterResponse,
};
use std::ops::ControlFlow;
use apollo_router::ServiceBuilderExt;
use apollo_router::layers::ServiceBuilderExt;
use tower::ServiceExt;
use tower::ServiceBuilder;
{{/if}}
{{#if type_tracing}}
use apollo_router::{
register_plugin, ResponseBody, RouterRequest, RouterResponse,
};
use apollo_router::ServiceBuilderExt;
use apollo_router::layers::ServiceBuilderExt;
use tower::ServiceExt;
use tower::ServiceBuilder;
{{/if}}
Expand Down Expand Up @@ -111,10 +111,10 @@ impl Plugin for {{pascal_name}} {
) -> BoxService<RouterRequest, RouterResponse<BoxStream<'static, ResponseBody>>, BoxError> {

ServiceBuilder::new()
.checkpoint_async(|request : RouterRequest| Box::pin(async {
.checkpoint_async(|request : RouterRequest| async {
// Do some async call here to auth, and decide if to continue or not.
Ok(ControlFlow::Continue(request))
}))
})
.buffered()
.service(service)
.boxed()
Expand Down Expand Up @@ -162,14 +162,14 @@ register_plugin!("{{project_name}}", "{{snake_name}}", {{pascal_name}});
mod tests {
use super::{Conf, {{pascal_name}}};

use apollo_router::utils::test::IntoSchema::Canned;
use apollo_router::utils::test::PluginTestHarness;
use apollo_router::{Plugin, ResponseBody};
use apollo_router::plugin::test::IntoSchema::Canned;
use apollo_router::plugin::test::PluginTestHarness;
use apollo_router::{plugin::Plugin, ResponseBody};
use tower::BoxError;

#[tokio::test]
async fn plugin_registered() {
apollo_router::plugins()
apollo_router::plugin::plugins()
.get("{{project_name}}.{{snake_name}}")
.expect("Plugin not found")
.create_instance(&serde_json::json!({"message" : "Starting my plugin"}))
Expand Down
1 change: 0 additions & 1 deletion apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ tracing-core = "0.1.26"
tracing-futures = { version = "0.2.5", features = ["futures-03"] }
tracing-opentelemetry = "0.17.2"
tracing-subscriber = { version = "0.3.11", features = ["env-filter", "json"] }
typed-builder = "0.10.0"
url = { version = "2.2.2", features = ["serde"] }
urlencoding = "2.1.0"
yaml-rust = "0.4.5"
Expand Down
Loading