When approved, this PR will merge into the 1.57.0 branch which will β upon being approved itself β merge into main.
Things to review in this PR:
Changelog correctness (There is a preview below, but it is not necessarily the most up to date. See the Files Changed for the true reality.)
Version bumps
That it targets the right release branch (1.57.0 in this case!).
[!IMPORTANT]
If you have enabled Distributed query plan caching, updates to the query planner in this release will result in query plan caches being re-generated rather than re-used. On account of this, you should anticipate additional cache regeneration cost when updating between these versions while the new query plans come into service.
Schema introspection in the router now runs natively without JavaScript. We have high confidence that the new native implementation returns responses that match the previous Javascript implementation, based on differential testing: fuzzing arbitrary queries against a large schema, and testing a corpus of customer schemas against a comprehensive query.
Changes to the router's YAML configuration:
The experimental_introspection_mode key has been removed, with the new mode as the only behavior in this release.
The supergraph.query_planning.legacy_introspection_caching key is removed, with the behavior in this release now similar to what was false: introspection responses are not part of the query plan cache but instead in a separate, small in-memoryβonly cache.
When using the above deprecated configuration options, the router's automatic configuration migration will ensure that existing configuration continue to work until the next major version of the router. To simplify major upgrades, we recommend reviewing incremental updates to your YAML configuration by comparing the output of ./router config upgrade --config path/to/config.yaml with your existing configuration.
Support new request_context selector for telemetry (PR #6160)
The router supports a new request_context selector for telemetry that enables access to the supergraph schema ID.
You can configure the context to access the supergraph schema ID at the router service level:
telemetry:
instrumentation:
events:
router:
my.request_event:
message: "my request event message"
level: info
on: request
attributes:
schema.id:
request_context: "apollo::supergraph_schema_id" # The key containing the supergraph schema id
You can use the selector in any service at any stage. While this example applies to events attributes, the selector can also be used on spans and instruments.
Support reading and setting port on request URIs using Rhai (Issue #5437)
Custom Rhai scripts in the router now support the request.uri.port and request.subgraph.uri.port functions for reading and setting URI ports. These functions enable you to update the full URI for subgraph fetches. For example:
fn subgraph_service(service, subgraph){
service.map_request(|request|{
log_info(``);
if request.subgraph.uri.port == {} {
log_info("Port is not explicitly set");
}
request.subgraph.uri.host = "api.apollographql.com";
request.subgraph.uri.path = "/api/graphql";
request.subgraph.uri.port = 1234;
log_info(``);
});
}
Fix various edge cases for __typename field (PR #6009)
The router now correctly handles the __typename field used on operation root types, even when the subgraph's root type has a name that differs from the supergraph's root type.
For example, given a query like this:
{
...RootFragment
}
fragment RootFragment on Query {
__typename
me {
name
}
}
Even if the subgraph's root type returns a __typename that differs from Query, the router will still use Query as the value of the __typename field.
This change also includes fixes for other edge cases related to the handling of __typename fields. For a detailed technical description of the edge cases that were fixed, please see this description.
Support uri and method properties on router "request" objects in Rhai (PR #6147)
The router now supports accessing request.uri and request.method properties from custom Rhai scripts. Previously, when trying to access request.uri and request.method on a router request in Rhai, the router would return error messages stating the properties were undefined.
Cost calculation for subgraph requests with named fragments (PR #6162)
In some cases where subgraph GraphQL operations contain named fragments and abstract types, demand control used the wrong type for cost calculation, and could reject valid operations. Now, the correct type is used.
This fixes errors of the form:
Attempted to look up a field on type MyInterface, but the field does not exist
[ ] events - Stress test for events with a lot of users and deduplication ENABLED
[ ] events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
[ ] events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
[ ] events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
[ ] events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
[ ] events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
π Features
Remove legacy schema introspection (PR #6139)
Schema introspection in the router now runs natively without JavaScript. We have high confidence that the new native implementation returns responses that match the previous Javascript implementation, based on differential testing: fuzzing arbitrary queries against a large schema, and testing a corpus of customer schemas against a comprehensive query.
Changes to the router's YAML configuration:
experimental_introspection_mode
key has been removed, with thenew
mode as the only behavior in this release.supergraph.query_planning.legacy_introspection_caching
key is removed, with the behavior in this release now similar to what wasfalse
: introspection responses are not part of the query plan cache but instead in a separate, small in-memoryβonly cache.When using the above deprecated configuration options, the router's automatic configuration migration will ensure that existing configuration continue to work until the next major version of the router. To simplify major upgrades, we recommend reviewing incremental updates to your YAML configuration by comparing the output of
./router config upgrade --config path/to/config.yaml
with your existing configuration.By @SimonSapin in https://github.com/apollographql/router/pull/6139
Support new
request_context
selector for telemetry (PR #6160)The router supports a new
request_context
selector for telemetry that enables access to the supergraph schema ID.You can configure the context to access the supergraph schema ID at the router service level:
You can use the selector in any service at any stage. While this example applies to
events
attributes, the selector can also be used on spans and instruments.By @bnjjj in https://github.com/apollographql/router/pull/6160
Support reading and setting
port
on request URIs using Rhai (Issue #5437)Custom Rhai scripts in the router now support the
request.uri.port
andrequest.subgraph.uri.port
functions for reading and setting URI ports. These functions enable you to update the full URI for subgraph fetches. For example:By @lleadbet in https://github.com/apollographql/router/pull/5439
π Fixes
Fix various edge cases for
__typename
field (PR #6009)The router now correctly handles the
__typename
field used on operation root types, even when the subgraph's root type has a name that differs from the supergraph's root type.For example, given a query like this:
Even if the subgraph's root type returns a
__typename
that differs fromQuery
, the router will still useQuery
as the value of the__typename
field.This change also includes fixes for other edge cases related to the handling of
__typename
fields. For a detailed technical description of the edge cases that were fixed, please see this description.By @IvanGoncharov in https://github.com/apollographql/router/pull/6009
Support
uri
andmethod
properties on router "request" objects in Rhai (PR #6147)The router now supports accessing
request.uri
andrequest.method
properties from custom Rhai scripts. Previously, when trying to accessrequest.uri
andrequest.method
on a router request in Rhai, the router would return error messages stating the properties were undefined.An example Rhai script using these properties:
By @andrewmcgivery in https://github.com/apollographql/router/pull/6114
Cost calculation for subgraph requests with named fragments (PR #6162)
In some cases where subgraph GraphQL operations contain named fragments and abstract types, demand control used the wrong type for cost calculation, and could reject valid operations. Now, the correct type is used.
This fixes errors of the form:
By @goto-bus-stop in https://github.com/apollographql/router/pull/6162
Federation v2.9.3 (PR #6161)
This release updates to Federation v2.9.3, with query planner fixes:
__typename
may be omitted in the subgraph query.@key
/@requires
selection sets were not optimized away.@context
/@fromContext
.By @sachindshinde in https://github.com/apollographql/router/pull/6161