Skip to content

Commit

Permalink
Merge pull request #109 from apollographql/fed2-ga-release
Browse files Browse the repository at this point in the history
Update to GA release
Bump node-fetch from 2.6.0 to 2.6.1 (#40)

Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](node-fetch/node-fetch@v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Add operation name to subqueries
  • Loading branch information
bryn committed Apr 12, 2022
1 parent fe1c3cb commit 5cc4d5e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 7 deletions.
3 changes: 3 additions & 0 deletions NEXT_CHANGELOG.md
Expand Up @@ -49,6 +49,9 @@ Jaeger and Zipkin telemetry config produced JSON schema that was invalid.
### Early return a better error when introspection is disabled [PR #751](https://github.com/apollographql/router/pull/751)
Instead of returning an error coming from the query planner, we are now returning a proper error explaining that the introspection has been disabled.

### Add operation name to subquery fetches [PR #840](https://github.com/apollographql/router/pull/840)
If present in the query plan fetch noede, the operation name will be added to sub-fetches.

## 馃洜 Maintenance
### Configuration files validated [PR #830](https://github.com/apollographql/router/pull/782)
Router configuration files within the project are now largely validated via unit test.
Expand Down
5 changes: 5 additions & 0 deletions apollo-router-core/src/plugin_utils/mock/subgraph.rs
Expand Up @@ -35,6 +35,11 @@ impl Service<SubgraphRequest> for MockSubgraph {
let response = if let Some(response) = self.mocks.get(req.http_request.body()) {
builder.data(response.data.clone()).build().into()
} else {
tracing::error!(
"could not find mock for query: {}",
serde_json::to_string(req.http_request.body())
.expect("could not serialise request")
);
builder
.errors(vec![crate::Error {
message: "couldn't find mock for query".to_string(),
Expand Down
8 changes: 4 additions & 4 deletions apollo-router-core/src/plugins/include_subgraph_errors.rs
Expand Up @@ -129,27 +129,27 @@ mod test {
) -> BoxCloneService<RouterRequest, RouterResponse, BoxError> {
let account_mocks = vec![
(
r#"{"query":"query TopProducts__accounts__3($representations:[_Any!]!){_entities(representations:$representations){...on User{name}}}","variables":{"representations":[{"__typename":"User","id":"1"},{"__typename":"User","id":"2"},{"__typename":"User","id":"1"}]}}"#,
r#"{"query":"query TopProducts__accounts__3($representations:[_Any!]!){_entities(representations:$representations){...on User{name}}}","operationName":"TopProducts__accounts__3","variables":{"representations":[{"__typename":"User","id":"1"},{"__typename":"User","id":"2"},{"__typename":"User","id":"1"}]}}"#,
r#"{"data":{"_entities":[{"name":"Ada Lovelace"},{"name":"Alan Turing"},{"name":"Ada Lovelace"}]}}"#
)
].into_iter().map(|(query, response)| (serde_json::from_str(query).unwrap(), serde_json::from_str(response).unwrap())).collect();
let account_service = MockSubgraph::new(account_mocks);

let review_mocks = vec![
(
r#"{"query":"query TopProducts__reviews__1($representations:[_Any!]!){_entities(representations:$representations){...on Product{reviews{id product{__typename upc}author{__typename id}}}}}","variables":{"representations":[{"__typename":"Product","upc":"1"},{"__typename":"Product","upc":"2"}]}}"#,
r#"{"query":"query TopProducts__reviews__1($representations:[_Any!]!){_entities(representations:$representations){...on Product{reviews{id product{__typename upc}author{__typename id}}}}}","operationName":"TopProducts__reviews__1","variables":{"representations":[{"__typename":"Product","upc":"1"},{"__typename":"Product","upc":"2"}]}}"#,
r#"{"data":{"_entities":[{"reviews":[{"id":"1","product":{"__typename":"Product","upc":"1"},"author":{"__typename":"User","id":"1"}},{"id":"4","product":{"__typename":"Product","upc":"1"},"author":{"__typename":"User","id":"2"}}]},{"reviews":[{"id":"2","product":{"__typename":"Product","upc":"2"},"author":{"__typename":"User","id":"1"}}]}]}}"#
)
].into_iter().map(|(query, response)| (serde_json::from_str(query).unwrap(), serde_json::from_str(response).unwrap())).collect();
let review_service = MockSubgraph::new(review_mocks);

let product_mocks = vec![
(
r#"{"query":"query TopProducts__products__0($first:Int){topProducts(first:$first){__typename upc name}}","variables":{"first":2}}"#,
r#"{"query":"query TopProducts__products__0($first:Int){topProducts(first:$first){__typename upc name}}","operationName":"TopProducts__products__0","variables":{"first":2}}"#,
r#"{"data":{"topProducts":[{"__typename":"Product","upc":"1","name":"Table"},{"__typename":"Product","upc":"2","name":"Couch"}]}}"#
),
(
r#"{"query":"query TopProducts__products__2($representations:[_Any!]!){_entities(representations:$representations){...on Product{name}}}","variables":{"representations":[{"__typename":"Product","upc":"1"},{"__typename":"Product","upc":"1"},{"__typename":"Product","upc":"2"}]}}"#,
r#"{"query":"query TopProducts__products__2($representations:[_Any!]!){_entities(representations:$representations){...on Product{name}}}","operationName":"TopProducts__products__2","variables":{"representations":[{"__typename":"Product","upc":"1"},{"__typename":"Product","upc":"1"},{"__typename":"Product","upc":"2"}]}}"#,
r#"{"data":{"_entities":[{"name":"Table"},{"name":"Table"},{"name":"Couch"}]}}"#
)
].into_iter().map(|(query, response)| (serde_json::from_str(query).unwrap(), serde_json::from_str(response).unwrap())).collect();
Expand Down
5 changes: 5 additions & 0 deletions apollo-router-core/src/query_planner/mod.rs
Expand Up @@ -268,6 +268,9 @@ pub(crate) mod fetch {
/// The GraphQL subquery that is used for the fetch.
operation: String,

/// The GraphQL subquery operation name.
operation_name: Option<String>,

/// The GraphQL operation kind that is used for the fetch.
operation_kind: OperationKind,
}
Expand Down Expand Up @@ -351,6 +354,7 @@ pub(crate) mod fetch {
let FetchNode {
operation,
operation_kind,
operation_name,
service_name,
..
} = self;
Expand Down Expand Up @@ -383,6 +387,7 @@ pub(crate) mod fetch {
.body(
Request::builder()
.query(operation)
.operation_name(operation_name.clone())
.variables(Arc::new(variables.clone()))
.build(),
)
Expand Down
@@ -1,6 +1,5 @@
---
source: apollo-router-core/src/query_planner/bridge_query_planner.rs
assertion_line: 132
expression: result
---
QueryPlan {
Expand All @@ -10,6 +9,7 @@ QueryPlan {
requires: [],
variable_usages: [],
operation: "{me{name{first last}}}",
operation_name: None,
operation_kind: Query,
},
),
Expand Down
@@ -1,8 +1,6 @@
---
source: apollo-router-core/src/query_planner/mod.rs
assertion_line: 467
expression: query_plan

---
Sequence {
nodes: [
Expand All @@ -12,6 +10,7 @@ Sequence {
requires: [],
variable_usages: [],
operation: "{topProducts{__typename ...on Book{__typename isbn}...on Furniture{name}}product(upc:\"1\"){__typename ...on Book{__typename isbn}...on Furniture{name}}}",
operation_name: None,
operation_kind: Query,
},
),
Expand Down Expand Up @@ -61,6 +60,7 @@ Sequence {
"test_variable",
],
operation: "query($representations:[_Any!]!){_entities(representations:$representations){...on Book{__typename isbn title year}}}",
operation_name: None,
operation_kind: Query,
},
),
Expand Down Expand Up @@ -120,6 +120,7 @@ Sequence {
],
variable_usages: [],
operation: "query($representations:[_Any!]!){_entities(representations:$representations){...on Book{name}}}",
operation_name: None,
operation_kind: Query,
},
),
Expand Down Expand Up @@ -168,6 +169,7 @@ Sequence {
],
variable_usages: [],
operation: "query($representations:[_Any!]!){_entities(representations:$representations){...on Book{__typename isbn title year}}}",
operation_name: None,
operation_kind: Query,
},
),
Expand Down Expand Up @@ -226,6 +228,7 @@ Sequence {
],
variable_usages: [],
operation: "query($representations:[_Any!]!){_entities(representations:$representations){...on Book{name}}}",
operation_name: None,
operation_kind: Query,
},
),
Expand Down

0 comments on commit 5cc4d5e

Please sign in to comment.