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
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The **Apollo Router** is a configurable, high-performance **graph router** for a

## Development

You will need a recent version of rust (`1.63` works well as of writing).
You will need a recent version of rust (`1.65` works well as of writing).
Installing rust [using rustup](https://www.rust-lang.org/tools/install) is
the recommended way to do it as it will install rustup, rustfmt and other
goodies that are not always included by default in other rust distribution channels:
Expand Down
6 changes: 6 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ This test was failing frequently due to it being a timing test being run in a si

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

### Update to Rust 1.65 ([Issue #2220](https://github.com/apollographql/router/issues/2220))

Rust MSRV incremented to 1.65.

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

## 📚 Documentation
### Create yaml config design guidance ([Issue #2158](https://github.com/apollographql/router/pull/2158))

Expand Down
2 changes: 1 addition & 1 deletion apollo-router-scaffold/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ mod test {

// best effort to prepare the output directory
let _ = std::fs::remove_dir_all(&output_dir);
copy_dir::copy_dir(&temp_dir, &output_dir)
copy_dir::copy_dir(temp_dir, &output_dir)
.expect("couldn't copy test_scaffold_output directory");
anyhow::anyhow!(
"scaffold test failed: {e}\nYou can find the scaffolded project at '{}'",
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "A configurable, high-performance routing runtime for Apollo Feder
license = "LicenseRef-ELv2"

# renovate-automation: rustc version
rust-version = "1.63.0"
rust-version = "1.65.0"
edition = "2021"
build = "build/main.rs"

Expand Down
8 changes: 4 additions & 4 deletions apollo-router/src/axum_factory/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1577,19 +1577,19 @@ async fn deferred_response_shape() -> Result<(), ApolloRouterError> {

let first = response.chunk().await.unwrap().unwrap();
assert_eq!(
std::str::from_utf8(&*first).unwrap(),
std::str::from_utf8(&first).unwrap(),
"\r\n--graphql\r\ncontent-type: application/json\r\n\r\n{\"data\":{\"test\":\"hello\"},\"hasNext\":true}\r\n--graphql\r\n"
);

let second = response.chunk().await.unwrap().unwrap();
assert_eq!(
std::str::from_utf8(&*second).unwrap(),
std::str::from_utf8(&second).unwrap(),
"content-type: application/json\r\n\r\n{\"hasNext\":true,\"incremental\":[{\"data\":{\"other\":\"world\"},\"path\":[]}]}\r\n--graphql\r\n"
);

let third = response.chunk().await.unwrap().unwrap();
assert_eq!(
std::str::from_utf8(&*third).unwrap(),
std::str::from_utf8(&third).unwrap(),
"content-type: application/json\r\n\r\n{\"hasNext\":false}\r\n--graphql--\r\n"
);

Expand Down Expand Up @@ -1640,7 +1640,7 @@ async fn multipart_response_shape_with_one_chunk() -> Result<(), ApolloRouterErr

let first = response.chunk().await.unwrap().unwrap();
assert_eq!(
std::str::from_utf8(&*first).unwrap(),
std::str::from_utf8(&first).unwrap(),
"\r\n--graphql\r\ncontent-type: application/json\r\n\r\n{\"data\":{\"test\":\"hello\"},\"hasNext\":false}\r\n--graphql--\r\n"
);

Expand Down
6 changes: 4 additions & 2 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,11 @@ impl HealthCheck {
enabled: enabled.unwrap_or_else(default_health_check),
}
}
}

// Used in tests
#[allow(dead_code)]
#[cfg(test)]
#[buildstructor::buildstructor]
impl HealthCheck {
#[builder]
pub(crate) fn fake_new(listen: Option<ListenAddr>, enabled: Option<bool>) -> Self {
Self {
Expand Down
6 changes: 3 additions & 3 deletions apollo-router/src/plugins/expose_query_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ mod tests {
let supergraph = build_mock_supergraph(plugin).await;
execute_supergraph_test(
VALID_QUERY,
&*EXPECTED_RESPONSE_WITH_QUERY_PLAN,
&EXPECTED_RESPONSE_WITH_QUERY_PLAN,
supergraph.clone(),
)
.await;
// let's try that again
execute_supergraph_test(VALID_QUERY, &*EXPECTED_RESPONSE_WITH_QUERY_PLAN, supergraph).await;
execute_supergraph_test(VALID_QUERY, &EXPECTED_RESPONSE_WITH_QUERY_PLAN, supergraph).await;
}

#[tokio::test]
Expand All @@ -243,7 +243,7 @@ mod tests {
let supergraph = build_mock_supergraph(plugin).await;
execute_supergraph_test(
VALID_QUERY,
&*EXPECTED_RESPONSE_WITHOUT_QUERY_PLAN,
&EXPECTED_RESPONSE_WITHOUT_QUERY_PLAN,
supergraph,
)
.await;
Expand Down
20 changes: 10 additions & 10 deletions apollo-router/src/plugins/include_subgraph_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,31 +214,31 @@ mod test {
// Build a redacting plugin
let plugin = get_redacting_plugin(&serde_json::json!({ "all": false })).await;
let router = build_mock_router(plugin).await;
execute_router_test(VALID_QUERY, &*EXPECTED_RESPONSE, router).await;
execute_router_test(VALID_QUERY, &EXPECTED_RESPONSE, router).await;
}

#[tokio::test]
async fn it_redacts_all_subgraphs_explicit_redact() {
// Build a redacting plugin
let plugin = get_redacting_plugin(&serde_json::json!({ "all": false })).await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*REDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &REDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
async fn it_redacts_all_subgraphs_implicit_redact() {
// Build a redacting plugin
let plugin = get_redacting_plugin(&serde_json::json!({})).await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*REDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &REDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
async fn it_does_not_redact_all_subgraphs_explicit_allow() {
// Build a redacting plugin
let plugin = get_redacting_plugin(&serde_json::json!({ "all": true })).await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*UNREDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &UNREDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
Expand All @@ -247,7 +247,7 @@ mod test {
let plugin =
get_redacting_plugin(&serde_json::json!({ "subgraphs": {"products": true }})).await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*UNREDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &UNREDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
Expand All @@ -256,7 +256,7 @@ mod test {
let plugin =
get_redacting_plugin(&serde_json::json!({ "subgraphs": {"reviews": true }})).await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*REDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &REDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
Expand All @@ -267,7 +267,7 @@ mod test {
)
.await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*UNREDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &UNREDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
Expand All @@ -278,7 +278,7 @@ mod test {
)
.await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*REDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &REDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
Expand All @@ -289,7 +289,7 @@ mod test {
)
.await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_PRODUCT_QUERY, &*UNREDACTED_PRODUCT_RESPONSE, router).await;
execute_router_test(ERROR_PRODUCT_QUERY, &UNREDACTED_PRODUCT_RESPONSE, router).await;
}

#[tokio::test]
Expand All @@ -300,6 +300,6 @@ mod test {
)
.await;
let router = build_mock_router(plugin).await;
execute_router_test(ERROR_ACCOUNT_QUERY, &*REDACTED_ACCOUNT_RESPONSE, router).await;
execute_router_test(ERROR_ACCOUNT_QUERY, &REDACTED_ACCOUNT_RESPONSE, router).await;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub(crate) struct Exporter {
enum TreeData {
Request(Result<Box<crate::spaceport::Trace>, Error>),
Supergraph {
http: Http,
http: Box<Http>,
client_name: Option<String>,
client_version: Option<String>,
operation_signature: String,
Expand Down Expand Up @@ -210,7 +210,7 @@ impl Exporter {
}

fn extract_trace(&mut self, span: SpanData) -> Result<Box<crate::spaceport::Trace>, Error> {
self.extract_data_from_spans(&span, &span)?
self.extract_data_from_spans(&span)?
.pop()
.and_then(|node| {
if let TreeData::Request(trace) = node {
Expand All @@ -222,18 +222,14 @@ impl Exporter {
.expect("root trace must exist because it is constructed on the request span, qed")
}

fn extract_data_from_spans(
&mut self,
root_span: &SpanData,
span: &SpanData,
) -> Result<Vec<TreeData>, Error> {
fn extract_data_from_spans(&mut self, span: &SpanData) -> Result<Vec<TreeData>, Error> {
let (mut child_nodes, errors) = self
.spans_by_parent_id
.pop_entry(&span.span_context.span_id())
.map(|(_, spans)| spans)
.unwrap_or_default()
.into_iter()
.map(|span| self.extract_data_from_spans(root_span, &span))
.map(|span| self.extract_data_from_spans(&span))
.fold((Vec::new(), Vec::new()), |(mut oks, mut errors), next| {
match next {
Ok(mut children) => oks.append(&mut children),
Expand Down Expand Up @@ -315,7 +311,7 @@ impl Exporter {
SUPERGRAPH_SPAN_NAME => {
//Currently some data is in the supergraph span as we don't have the a request hook in plugin.
child_nodes.push(TreeData::Supergraph {
http: extract_http_data(span, &self.expose_trace_id_config),
http: Box::new(extract_http_data(span, &self.expose_trace_id_config)),
client_name: span.attributes.get(&CLIENT_NAME).and_then(extract_string),
client_version: span
.attributes
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 @@ -503,7 +503,7 @@ mod test {
// Build a traffic shaping plugin
let plugin = get_traffic_shaping_plugin(&config).await;
let router = build_mock_router_with_variable_dedup_optimization(plugin).await;
execute_router_test(VALID_QUERY, &*EXPECTED_RESPONSE, router).await;
execute_router_test(VALID_QUERY, &EXPECTED_RESPONSE, router).await;
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/query_planner/bridge_query_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl BridgeQueryPlanner {
},
usage_reporting,
} => {
let subselections = node.parse_subselections(&*self.schema)?;
let subselections = node.parse_subselections(&self.schema)?;
selections.subselections = subselections;
Ok(QueryPlannerContent::Plan {
plan: Arc::new(query_planner::QueryPlan {
Expand Down
4 changes: 2 additions & 2 deletions apollo-router/src/query_planner/caching_query_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ where
}

if let Some(QueryPlannerContent::Plan { plan, .. }) = &content {
match (&plan.usage_reporting).serialize(Serializer) {
match (plan.usage_reporting).serialize(Serializer) {
Ok(v) => {
context.insert_json_value(USAGE_REPORTING, v);
}
Expand Down Expand Up @@ -127,7 +127,7 @@ where
match res {
Ok(content) => {
if let QueryPlannerContent::Plan { plan, .. } = &content {
match (&plan.usage_reporting).serialize(Serializer) {
match (plan.usage_reporting).serialize(Serializer) {
Ok(v) => {
context.insert_json_value(USAGE_REPORTING, v);
}
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/query_planner/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl FetchNode {
parameters
.schema
.subgraphs()
.find_map(|(name, url)| (name == service_name).then(|| url))
.find_map(|(name, url)| (name == service_name).then_some(url))
.unwrap_or_else(|| {
panic!(
"schema uri for subgraph '{}' should already have been checked",
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/router_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl SupergraphServiceConfigurator for YamlSupergraphServiceFactory {
let subgraph_service = match plugins
.iter()
.find(|i| i.0.as_str() == APOLLO_TRAFFIC_SHAPING)
.and_then(|plugin| (&*plugin.1).as_any().downcast_ref::<TrafficShaping>())
.and_then(|plugin| (*plugin.1).as_any().downcast_ref::<TrafficShaping>())
{
Some(shaping) => {
Either::A(shaping.subgraph_service_internal(name, SubgraphService::new(name)))
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/diy/dockerfiles/Dockerfile.repo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use the rust build image from docker as our base
# renovate-automation: rustc version
FROM rust:1.63.0 as build
FROM rust:1.65.0 as build

# Set our working directory for the build
WORKDIR /usr/src/router
Expand Down
4 changes: 2 additions & 2 deletions licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -10220,7 +10220,7 @@ <h4>Used by:</h4>
<ul class="license-used-by">
<li><a href=" https://github.com/abumni/inflector ">str_inflector</a></li>
</ul>
<pre class="license-text">Copyright (c) &lt;year&gt; &lt;owner&gt; All rights reserved.
<pre class="license-text">Copyright (c) &lt;year&gt; &lt;owner&gt;

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down Expand Up @@ -10369,7 +10369,7 @@ <h4>Used by:</h4>
<ul class="license-used-by">
<li><a href=" https://github.com/dropbox/rust-alloc-no-stdlib ">alloc-stdlib</a></li>
</ul>
<pre class="license-text">Copyright (c) &lt;year&gt; &lt;owner&gt;. All rights reserved.
<pre class="license-text">Copyright (c) &lt;year&gt; &lt;owner&gt;.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
# renovate-automation: rustc version
channel = "1.63.0"
channel = "1.65.0"
components = [ "rustfmt", "clippy" ]