github apollographql/router v1.19.0

latest releases: v1.49.1, v1.49.1-rc.0, v1.49.0...
13 months ago

Note
This release focused a notable amount of effort on improving both CPU usage and memory utilization/fragmentization. Our testing and pre-release feedback has been overwhelmingly positive. 🙌

🚀 Features

GraphOS Enterprise: require_authentication option to reject unauthenticated requests (Issue #2866)

While the authentication plugin validates queries with JWT, it does not reject unauthenticated requests, and leaves that to other layers. This allows co-processors to handle other authentication methods, and plugins at later layers to authorize the request or not. Typically, this was done in rhai.

This now adds an option to the Router's YAML configuration to reject unauthenticated requests. It can be used as follows:

authorization:
  require_authentication: true

The plugin will check for the presence of the apollo_authentication::JWT::claims key in the request context as proof that the request is authenticated.

By @Geal in #3002

🐛 Fixes

Prevent span attributes from being formatted to write logs

We do not show span attributes in our logs, but the log formatter still spends time formatting them to a string, even when there will be no logs written for the trace. This adds the NullFieldFormatter that entirely avoids formatting the attributes to improve performance.

By @Geal in #2890

Federation v2.4.5

This release bumps the Router's Federation support from v2.4.2 to v2.4.5, which brings in notable query planner fixes from v2.4.3 and v2.4.5. Federation v2.4.4 will not exist due to a publishing failure. Of note from those releases, this brings query planner fixes that:

  • Improves the heuristics used to try to reuse the query named fragments in subgraph fetches. Said fragment will be reused (apollographql/federation#2541) more often, which can lead to smaller subgraph queries (and hence overall faster processing).

  • Fix potential assertion error during query planning in some multi-field @requires case. This error could be triggered (#2575) when a field in a @requires depended on another field that was also part of that same requires (for instance, if a field has a @requires(fields: "id otherField") and that id is also a key necessary to reach the subgraph providing otherField).

    The assertion error thrown in that case contained the message Root groups (...) should have no remaining groups unhandled (...)

By @abernix in #3107

Add support for throwing GraphQL errors in Rhai responses (Issue #3069)

It's possible to throw a GraphQL error from Rhai when processing a request. This extends the capability to include errors when processing a response.

Refer to the Terminating client requests section of the Rhai api documentation to learn how to throw GraphQL payloads.

By @garypen in #3089

Use a parking-lot mutex in Context to avoid contention (Issue #2751)

Request context requires synchronized access to the busy timer, and previously we used a futures aware mutex for that, but those are susceptible to contention. This replaces that mutex with a parking-lot synchronous mutex that is much faster.

By @Geal in #2885

Config and schema reloads now use async IO (Issue #2613)

If you were using local schema or config then previously the Router was performing blocking IO in an async thread. This could have caused stalls to serving requests.
The Router now uses async IO for all config and schema reloads.

Fixing the above surfaced an issue with the experimental force_hot_reload feature introduced for testing. This has also been fixed and renamed to force_reload.

experimental_chaos:
-    force_hot_reload: 1m
+    force_reload: 1m

By @BrynCooke in #3016

Improve subgraph coprocessor context processing (Issue #3058)

Each call to a subgraph co-processor could update the entire request context as a single operation. This is racy and could lead to difficult to predict context modifications depending on the order in which subgraph requests and responses are processed by the router.

This fix modifies the router so that subgraph co-processor context updates are merged within the existing context. This is still racy, but means that subgraphs are only racing to perform updates at the context key level, rather than across the entire context.

Future enhancements will provide a more comprehensive mechanism that will support some form of sequencing or change arbitration across subgraphs.

By @garypen in #3054

🛠 Maintenance

Add private component to the Context structure (Issue #2800)

There's a cost in using the Context structure during a request's lifecycle, due to JSON serialization and deserialization incurred when doing inter-plugin communication (e.g., between Rhai/coprocessors and Rust). For internal router usage, we now use a more efficient structure that avoids serialization costs of our private contextual properties which do not need to be exposed to plugins.

By @Geal in #2802

Adds an integration test for all YAML configuration files in ./examples (Issue #2932)

Adds an integration test that iterates over ./examples looking for .yaml files that don't have a Cargo.toml or .skipconfigvalidation sibling file, and then running setup_router_and_registry on them, fast failing on any errors along the way.

By @EverlastingBugstopper in #3097

Improve memory fragmentation and resource consumption by switching to jemalloc as the memory allocator on Linux (PR #2882)

Detailed memory investigation revealed significant memory fragmentation when using the default allocator, glibc, on Linux. Performance testing and flame-graph analysis suggested that using jemalloc on Linux would yield notable performance improvements. In our tests, this figure shows performance to be about 35% faster than the default allocator, on account of spending less time managing memory fragmentation.

Not everyone will see a 35% performance improvement. Depending on your usage patterns, you may see more or less than this. If you see a regression, please file an issue with details.

We have no reason to believe that there are allocation problems on other platforms, so this change is confined to Linux.

By @garypen in #2882

Improve performance by avoiding temporary allocations creating response paths (PR #2854)

Response formatting generated many temporary allocations while creating response paths. By making a reference based type to hold these paths, we can prevent those allocations and improve performance.

By @Geal in #2854

Don't miss a new router release

NewReleases is sending notifications on new releases.