Skip to content

Commit

Permalink
Update router bridge and add option for reuse_query_fragments (#3453)
Browse files Browse the repository at this point in the history
### Update router bridge and add option for `reuse_query_fragments`
([Issue #3452](#3452))

Federation v2.4.9 enabled a new feature for [query fragment
reuse](apollographql/federation#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.
Fixes #3452

<!-- start metadata -->

**Checklist**

Complete the checklist (and note appropriate exceptions) before a final
PR is raised.

- [ ] Changes are compatible[^1]
- [ ] Documentation[^2] completed
- [ ] Performance impact assessed and acceptable
- Tests added and passing[^3]
    - [ ] Unit Tests
    - [ ] Integration Tests
    - [ ] Manual Tests

**Exceptions**

*Note any exceptions here*

**Notes**

[^1]. It may be appropriate to bring upcoming changes to the attention
of other (impacted) groups. Please endeavour to do this before seeking
PR approval. The mechanism for doing this will vary considerably, so use
your judgement as to how and when to do this.
[^2]. Configuration is an important part of many changes. Where
applicable please try to document configuration examples.
[^3]. Tick whichever testing boxes are applicable. If you are adding
Manual Tests:
- please document the manual testing (extensively) in the Exceptions.
- please raise a separate issue to automate the test and label it (or
ask for it to be labeled) as `manual test`

---------

Co-authored-by: bryn <bryn@apollographql.com>
  • Loading branch information
BrynCooke and bryn authored Jul 18, 2023
1 parent 593910b commit c9d2b83
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .changesets/fix_federation_fragments.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions apollo-router/src/configuration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -554,13 +559,15 @@ impl Supergraph {
introspection: Option<bool>,
defer_support: Option<bool>,
query_planning: Option<QueryPlanning>,
reuse_query_fragments: Option<bool>,
) -> Self {
Self {
listen: listen.unwrap_or_else(default_graphql_listen),
path: path.unwrap_or_else(default_graphql_path),
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(),
}
}
}
Expand All @@ -575,13 +582,15 @@ impl Supergraph {
introspection: Option<bool>,
defer_support: Option<bool>,
query_planning: Option<QueryPlanning>,
reuse_query_fragments: Option<bool>,
) -> Self {
Self {
listen: listen.unwrap_or_else(test_listen),
path: path.unwrap_or_else(default_graphql_path),
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(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions apollo-router/src/introspection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ mod introspection_tests {
enable_defer: Some(true),
}),
graphql_validation: true,
reuse_query_fragments: Some(false),
},
)
.await
Expand Down
2 changes: 2 additions & 0 deletions apollo-router/src/query_planner/bridge_query_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
Expand Down Expand Up @@ -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?,
Expand Down

0 comments on commit c9d2b83

Please sign in to comment.