diff --git a/.changesets/fix_federation_fragments.md b/.changesets/fix_federation_fragments.md new file mode 100644 index 0000000000..06529862cc --- /dev/null +++ b/.changesets/fix_federation_fragments.md @@ -0,0 +1,13 @@ +### Update router bridge and add option for `reuse_query_fragments` ([Issue #3452](https://github.com/apollographql/router/issues/3452)) + +Federation v2.4.9 enabled a new feature for [query fragment reuse](https://github.com/apollographql/federation/pull/2639) that is causing issues for some users. + +A new option has been added to he router config file to opt into this feature: +```yaml +supergraph: + experimental_reuse_query_fragments: true +``` + +The default is disabled. + +By [@BrynCooke](https://github.com/BrynCooke) in https://github.com/apollographql/router/pull/3453 diff --git a/Cargo.lock b/Cargo.lock index d62795ea3c..506d2499e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4927,9 +4927,9 @@ dependencies = [ [[package]] name = "router-bridge" -version = "0.3.1+v2.4.9" +version = "0.4.0+v2.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b5cc00d70b7be23f008349426d6da0578c01931102fe2431051142c347154de" +checksum = "2ca7a000e3c4e1f6539581443354403f50d9a85b22c9a9a5572be0cf581c25df" dependencies = [ "anyhow", "async-channel", diff --git a/apollo-router/Cargo.toml b/apollo-router/Cargo.toml index 9a30429a7c..373bb4eb98 100644 --- a/apollo-router/Cargo.toml +++ b/apollo-router/Cargo.toml @@ -171,7 +171,7 @@ reqwest = { version = "0.11.18", default-features = false, features = [ "stream", ] } # note: this dependency should _always_ be pinned, prefix the version with an `=` -router-bridge = "=0.3.1+v2.4.9" +router-bridge = "=0.4.0+v2.4.10" rust-embed="6.8.1" rustls = "0.20.8" rustls-pemfile = "1.0.3" diff --git a/apollo-router/src/configuration/mod.rs b/apollo-router/src/configuration/mod.rs index 9ea6b7fb0f..0441579153 100644 --- a/apollo-router/src/configuration/mod.rs +++ b/apollo-router/src/configuration/mod.rs @@ -534,6 +534,11 @@ pub(crate) struct Supergraph { /// Default: false pub(crate) introspection: bool, + /// Enable reuse of query fragments + /// Default: false + #[serde(rename = "experimental_reuse_query_fragments")] + pub(crate) reuse_query_fragments: bool, + /// Set to false to disable defer support pub(crate) defer_support: bool, @@ -554,6 +559,7 @@ impl Supergraph { introspection: Option, defer_support: Option, query_planning: Option, + reuse_query_fragments: Option, ) -> Self { Self { listen: listen.unwrap_or_else(default_graphql_listen), @@ -561,6 +567,7 @@ impl Supergraph { introspection: introspection.unwrap_or_else(default_graphql_introspection), defer_support: defer_support.unwrap_or_else(default_defer_support), query_planning: query_planning.unwrap_or_default(), + reuse_query_fragments: reuse_query_fragments.unwrap_or_default(), } } } @@ -575,6 +582,7 @@ impl Supergraph { introspection: Option, defer_support: Option, query_planning: Option, + reuse_query_fragments: Option, ) -> Self { Self { listen: listen.unwrap_or_else(test_listen), @@ -582,6 +590,7 @@ impl Supergraph { introspection: introspection.unwrap_or_else(default_graphql_introspection), defer_support: defer_support.unwrap_or_else(default_defer_support), query_planning: query_planning.unwrap_or_default(), + reuse_query_fragments: reuse_query_fragments.unwrap_or_default(), } } } diff --git a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap index f6a524d3e4..fa76d7bac5 100644 --- a/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap +++ b/apollo-router/src/configuration/snapshots/apollo_router__configuration__tests__schema_generation.snap @@ -1482,6 +1482,7 @@ expression: "&schema" "listen": "127.0.0.1:4000", "path": "/", "introspection": false, + "experimental_reuse_query_fragments": false, "defer_support": true, "query_planning": { "experimental_cache": { @@ -1500,6 +1501,11 @@ expression: "&schema" "default": true, "type": "boolean" }, + "experimental_reuse_query_fragments": { + "description": "Enable reuse of query fragments Default: false", + "default": false, + "type": "boolean" + }, "introspection": { "description": "Enable introspection Default: false", "default": false, diff --git a/apollo-router/src/introspection.rs b/apollo-router/src/introspection.rs index 21ea92208f..fad7d54823 100644 --- a/apollo-router/src/introspection.rs +++ b/apollo-router/src/introspection.rs @@ -110,6 +110,7 @@ mod introspection_tests { enable_defer: Some(true), }), graphql_validation: true, + reuse_query_fragments: Some(false), }, ) .await diff --git a/apollo-router/src/query_planner/bridge_query_planner.rs b/apollo-router/src/query_planner/bridge_query_planner.rs index 777f4c0974..0dbc8f6ab2 100644 --- a/apollo-router/src/query_planner/bridge_query_planner.rs +++ b/apollo-router/src/query_planner/bridge_query_planner.rs @@ -58,6 +58,7 @@ impl BridgeQueryPlanner { let planner = Planner::new( sdl, QueryPlannerConfig { + reuse_query_fragments: Some(configuration.supergraph.reuse_query_fragments), incremental_delivery: Some(IncrementalDeliverySupport { enable_defer: Some(configuration.supergraph.defer_support), }), @@ -132,6 +133,7 @@ impl BridgeQueryPlanner { configuration.experimental_graphql_validation_mode, GraphQLValidationMode::Legacy | GraphQLValidationMode::Both ), + reuse_query_fragments: Some(configuration.supergraph.reuse_query_fragments), }, ) .await?,