Skip to content

Commit

Permalink
merge dev 1.57 (#6233)
Browse files Browse the repository at this point in the history
  • Loading branch information
lennyburdette authored Nov 6, 2024
2 parents 216e5a4 + ac21378 commit 28e232a
Show file tree
Hide file tree
Showing 62 changed files with 2,678 additions and 127 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### docs: correct authorization directive composition ([PR #6216](https://github.com/apollographql/router/pull/6216))

Make authorization directive composition clearer and correct code examples

By [@Meschreiber](https://github.com/Meschreiber) in https://github.com/apollographql/router/pull/6216
5 changes: 5 additions & 0 deletions .changesets/fix_geal_deduplication_processing_time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### do not count the wait time in deduplication as processing time ([PR #6207](https://github.com/apollographql/router/pull/6207))

waiting for a deduplicated request was incorrectly counted as time spent in the router overhead, while most of it was actually spent waiting for the subgraph response.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/6207
5 changes: 5 additions & 0 deletions .changesets/fix_geal_response_validation_errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### add errors for response validation ([Issue #5372](https://github.com/apollographql/router/issues/5372))

When formatting responses, the router is validating the data returned by subgraphs and replacing it with null values as appropriate. That validation phase is now adding errors when encountering the wrong type in a field requested by the client.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/5787
5 changes: 5 additions & 0 deletions .changesets/maint_bnjjj_fix_supergraph_events_span.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Don't create a stub span for supergraph events if it already has a current span ([PR #6096](https://github.com/apollographql/router/pull/6096))

Don't create useless span when we already have a span available to use the span's extensions.

By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/6096
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Query planner cache key improvements ([Issue #5160](https://github.com/apollographql/router/issues/5160))

> [!IMPORTANT]
> If you have enabled [Distributed query plan caching](https://www.apollographql.com/docs/router/configuration/distributed-caching/#distributed-query-plan-caching), this release changes the hashing algorithm used for the cache keys. On account of this, you should anticipate additional cache regeneration cost when updating between these versions while the new hashing algorithm comes into service.
This brings several performance improvements to the query plan cache key generation. In particular, it changes the distributed cache's key format, adding prefixes to the different key segments, to help in debugging.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/6206
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
version: 2.1

# Cache key bump: 1

# These "CircleCI Orbs" are reusable bits of configuration that can be shared
# across projects. See https://circleci.com/orbs/ for more information.
orbs:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ Default values of some GraphOS reporting metrics have been changed from v1.x to

* `telemetry.apollo.signature_normalization_algorithm` now defaults to `enhanced`. (In v1.x the default is `legacy`.)
* `telemetry.apollo.metrics_reference_mode` now defaults to `extended`. (In v1.x the default is `standard`.)
# [1.57.1] - 2024-10-31

## 🐛 Fixes

### Progressive override: fix query planner cache warmup ([PR #6108](https://github.com/apollographql/router/pull/6108))

This fixes an issue in progressive override where the override labels were not transmitted to the query planner during cache warmup. Queries were correctly using the overridden fields at first, but after an update, reverted to non overridden fields, and could not recover.

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

# [1.57.0] - 2024-10-22

Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

---

**Announcement:**
Join 1000+ engineers at GraphQL Summit for talks, workshops, and office hours, Oct 8-10 in NYC. [Get your pass here ->](https://summit.graphql.com/?utm_campaign=github_federation_readme)

---

# Apollo Router Core

The **Apollo Router Core** is a configurable, high-performance **graph router** written in Rust to run a [federated supergraph](https://www.apollographql.com/docs/federation/) that uses [Apollo Federation 2](https://www.apollographql.com/docs/federation/v2/federation-2/new-in-federation-2).
Expand Down
34 changes: 16 additions & 18 deletions apollo-federation/src/query_plan/query_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,26 @@ pub(crate) const CONTEXT_DIRECTIVE: &str = "context";

#[derive(Debug, Clone, Hash)]
pub struct QueryPlannerConfig {
/// Whether the query planner should try to reused the named fragments of the planned query in
/// Whether the query planner should try to reuse the named fragments of the planned query in
/// subgraph fetches.
///
/// This is often a good idea as it can prevent very large subgraph queries in some cases (named
/// fragments can make some relatively small queries (using said fragments) expand to a very large
/// query if all the spreads are inline). However, due to architecture of the query planner, this
/// optimization is done as an additional pass on the subgraph queries of the generated plan and
/// can thus increase the latency of building a plan. As long as query plans are sufficiently
/// cached, this should not be a problem, which is why this option is enabled by default, but if
/// the distribution of inbound queries prevents efficient caching of query plans, this may become
/// an undesirable trade-off and can be disabled in that case.
/// Reusing fragments requires complicated validations, so it can take a long time on large
/// queries with many fragments. This option may be removed in the future in favour of
/// [`generate_query_fragments`][QueryPlannerConfig::generate_query_fragments].
///
/// Defaults to true.
pub reuse_query_fragments: bool,

/// NOTE: **not implemented yet**
///
/// If enabled, the query planner will extract inline fragments into fragment
/// definitions before sending queries to subgraphs. This can significantly
/// reduce the size of the query sent to subgraphs, but may increase the time
/// it takes to plan the query.
/// reduce the size of the query sent to subgraphs.
///
/// Defaults to false.
pub generate_query_fragments: bool,

/// **TODO:** This option is not implemented, and the behaviour is *always enabled*.
/// <https://github.com/apollographql/router/pull/5871>
///
/// Whether to run GraphQL validation against the extracted subgraph schemas. Recommended in
/// non-production settings or when debugging.
///
Expand Down Expand Up @@ -112,8 +107,8 @@ impl Default for QueryPlannerConfig {
fn default() -> Self {
Self {
reuse_query_fragments: true,
subgraph_graphql_validation: false,
generate_query_fragments: false,
subgraph_graphql_validation: false,
incremental_delivery: Default::default(),
debug: Default::default(),
type_conditioned_fetching: Default::default(),
Expand All @@ -123,12 +118,15 @@ impl Default for QueryPlannerConfig {

#[derive(Debug, Clone, Default, Hash)]
pub struct QueryPlanIncrementalDeliveryConfig {
/// Enables @defer support by the query planner.
/// Enables `@defer` support in the query planner, breaking up the query plan with [DeferNode]s
/// as appropriate.
///
/// If false, operations with `@defer` are still accepted, but are planned as if they did not
/// contain `@defer` directives.
///
/// If set, then the query plan for queries having some @defer will contains some `DeferNode`
/// (see `query_plan/mod.rs`).
/// Defaults to false.
///
/// Defaults to false (meaning that the @defer are ignored).
/// [DeferNode]: crate::query_plan::DeferNode
pub enable_defer: bool,
}

Expand Down
16 changes: 16 additions & 0 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,22 @@ impl Configuration {
type_conditioned_fetching: self.experimental_type_conditioned_fetching,
}
}

pub(crate) fn rust_query_planner_config(
&self,
) -> apollo_federation::query_plan::query_planner::QueryPlannerConfig {
apollo_federation::query_plan::query_planner::QueryPlannerConfig {
reuse_query_fragments: self.supergraph.reuse_query_fragments.unwrap_or(true),
subgraph_graphql_validation: false,
generate_query_fragments: self.supergraph.generate_query_fragments,
incremental_delivery:
apollo_federation::query_plan::query_planner::QueryPlanIncrementalDeliveryConfig {
enable_defer: self.supergraph.defer_support,
},
type_conditioned_fetching: self.experimental_type_conditioned_fetching,
debug: Default::default(),
}
}
}

impl Default for Configuration {
Expand Down
14 changes: 14 additions & 0 deletions apollo-router/src/json_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ pub(crate) trait ValueExt {
#[track_caller]
fn is_object_of_type(&self, schema: &Schema, maybe_type: &str) -> bool;

/// value type
fn json_type_name(&self) -> &'static str;

/// Convert this value to an instance of `apollo_compiler::ast::Value`
fn to_ast(&self) -> apollo_compiler::ast::Value;

Expand Down Expand Up @@ -475,6 +478,17 @@ impl ValueExt for Value {
})
}

fn json_type_name(&self) -> &'static str {
match self {
Value::Array(_) => "array",
Value::Null => "null",
Value::Bool(_) => "boolean",
Value::Number(_) => "number",
Value::String(_) => "string",
Value::Object(_) => "object",
}
}

fn to_ast(&self) -> apollo_compiler::ast::Value {
match self {
Value::Null => apollo_compiler::ast::Value::Null,
Expand Down
10 changes: 7 additions & 3 deletions apollo-router/src/plugins/telemetry/config_new/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,9 +775,13 @@ where
}
// Stub span to make sure the custom attributes are saved in current span extensions
// It won't be extracted or sampled at all
let span = info_span!("supergraph_event_send_event");
let _entered = span.enter();
inner.send_event(attributes);
if Span::current().is_none() {
let span = info_span!("supergraph_event_send_event");
let _entered = span.enter();
inner.send_event(attributes);
} else {
inner.send_event(attributes);
}
}

fn on_error(&self, error: &BoxError, ctx: &Context) {
Expand Down
1 change: 1 addition & 0 deletions apollo-router/src/plugins/traffic_shaping/deduplication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ where
let mut receiver = waiter.subscribe();
drop(locked_wait_map);

let _guard = request.context.enter_active_request();
match receiver.recv().await {
Ok(value) => {
return value
Expand Down
Loading

0 comments on commit 28e232a

Please sign in to comment.