github apollographql/router v0.14.0

latest releases: v1.47.0-rc.0, v1.46.0, v1.46.0-rc.3...
21 months ago

[0.14.0] - 2022-08-02

❗ BREAKING ❗

Regex allow_any_origin behavior changed (PR #1444)

Setting allow_any_origin to true in the router configuration would previously automatically mirror the requested headers.
If you relied on this behavior, you now also need to set allow_any_header to true, as explained in the CORS documentation.

server:
  cors:
    allow_any_origin: true
    allow_any_header: true # mirror client's headers

The default CORS headers configuration of the router allows content-type, apollographql-client-version and apollographql-client-name.

By @o0Ignition0o in #1444

Modify the plugin new method to pass an initialisation structure (PR #1446)

This change alters the new method for plugins to pass a PluginInit struct.

We are making this change so that we can pass more information during plugin startup. The first change is that in addition to passing
the plugin configuration, we are now also passing the router supergraph sdl (Schema Definition Language) as a string.

There is a new example (supergraph_sdl) which illustrates how to use this new capability.

By @garypen in #1446

Remove the generic stream type from RouterResponse and ExecutionResponse (PR #1420)

This generic type complicates the API with limited benefit because we use BoxStream everywhere in plugins:

  • RouterResponse<BoxStream<'static, Response>> -> RouterResponse
  • ExecutionResponse<BoxStream<'static, Response>> -> ExecutionResponse

By @Geal in #1420

Remove the HTTP request from QueryPlannerRequest (PR #1439)

The content of QueryPlannerRequest is used as argument to the query planner and as a cache key,
so it should not change depending on the variables or HTTP headers.

By @Geal in #1439

Change PluggableRouterServiceBuilder methods (PR #1437)

with_naive_introspection and with_defer_support where two parameter-less methods
of this builder that enabled boolean configuration flags.
They have been removed and replaced by with_configuration
which takes Arc<apollo_router::Configuration>.
A Configuration value can be created from various formats by deserializing with serde.
The removed methods correspond to server.introspection and server.experimental_defer_support
configuration keys respectively.

By @SimonSapin in #1437

Changes to the SchemaKind enum (PR #1437)

The Instance variant is replaced with a variant named String that contains…
a String instead of Box<apollo_router::Schema>,
so you no longer need to parse the schema before giving it to the router.
Similarly, the Stream variant now contains a stream of Strings
instead of a stream of already-parsed Schemas.

By @SimonSapin in #1437

Schema no longer implements FromStr (PR #1437)

This means that str.parse::<apollo_router::Schema>() is no longer available.
If you still need a parsed Schema (see above),
use apollo_router::Schema(str, &configuration) instead.
To use the default apollo_router::Configuration
you can call apollo_router::Schema(str, &Default::default()).

By @SimonSapin in #1437

🚀 Features

Publish helm chart to OCI registry (PR #1447)

When we make a release, publish our helm chart to the same OCI registry that we use for our docker images.

For more information about using OCI registries with helm, see the helm documentation.

By @garypen in #1447

Configure Regex based CORS rules (PR #1444)

The router now supports regex based CORS rules, as explained in the docs
It also supports the allow_any_header setting that will mirror client's requested headers.

server:
  cors:
    match_origins:
      - "https://([a-z0-9]+[.])*api[.]example[.]com" # any host that uses https and ends with .api.example.com
    allow_any_header: true # mirror client's headers

The default CORS headers configuration of the router allows content-type, apollographql-client-version and apollographql-client-name.

By @o0Ignition0o in #1444

Add support of error section in telemetry to add custom attributes (PR #1443)

The telemetry is now able to hook at the error stage if router or a subgraph is returning an error. Here is an example of configuration:

telemetry:
  metrics:
    prometheus:
      enabled: true
    common:
      attributes:
        subgraph:
          all:
            errors: # Only works if it's a valid GraphQL error
              include_messages: true # Will include the error message in a message attribute
              extensions: # Include extension data
                - name: subgraph_error_extended_type # Name of the attribute
                  path: .type # JSON query path to fetch data from extensions

By @bnjjj in #1443

Experimental support for the @defer directive (PR #1182)

The router can now understand the @defer directive, used to tag parts of a query so the response is split into
multiple parts that are sent one by one.

⚠️ this is still experimental and not fit for production use yet

To activate it, add this option to the configuration file:

server:
  experimental_defer_support: true

By @Geal in #1182

Rewrite the caching API (PR #1281)

This introduces a new asynchronous caching API that opens the way to multi level caching (in memory and
database). The API revolves around an Entry structure that allows query deduplication and lets the
client decide how to generate the value to cache, instead of a complicated delegate system inside the
cache.

By @Geal in #1281

🐛 Fixes

Update serialization format for telemetry.tracing.otlp.grpc.metadata (PR #1391)

The metadata format now uses IndexMap<String, Vec<String>>.

By @me-diru in #1391

Update the scaffold template so it targets router v0.14.0 (PR #1431)

The cargo scaffold template will target the latest version of the router.

By @o0Ignition0o in #1248

Selection merging on non-object field aliases (PR #1406)

Fixed a bug where merging aliased fields would sometimes put nulls instead of expected values.

By @o0Ignition0o in #1432

A Rhai error instead of a Rust panic ([PR #1414 https://github.com//pull/1414))

In Rhai plugins, accessors that mutate the originating request are not available when in the subgraph phase. Previously, trying to mutate anyway would cause a Rust panic. This has been changed to a Rhai error instead.

By @SimonSapin in #1414

Optimizations (PR #1423)

  • Do not clone the client request during query plan execution
  • Do not clone the usage reporting
  • Avoid path allocations when iterating over JSON values

The benchmarks show that this change brings a 23% gain in requests per second compared to the main branch.

By @Geal in #1423

do not perform nested fetches if the parent one returned null (PR #1332

In a query of the form:

mutation {
	mutationA {
		mutationB
	}
}

If mutationA returned null, we should not execute mutationB.

By @Ty3uK in #1332

🛠 Maintenance

📚 Documentation

Updates wording and formatting of README.md

By @EverlastingBugstopper in #1445

What's Changed

New Contributors

Full Changelog: v0.12.0...v0.14.0

Don't miss a new router release

NewReleases is sending notifications on new releases.