[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.
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
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.
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 String
s
instead of a stream of already-parsed Schema
s.
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.
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
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
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.
🐛 Fixes
Update serialization format for telemetry.tracing.otlp.grpc.metadata (PR #1391)
The metadata format now uses IndexMap<String, Vec<String>>
.
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 null
s 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.
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
.
🛠 Maintenance
📚 Documentation
Updates wording and formatting of README.md
By @EverlastingBugstopper in #1445
What's Changed
- CI: Upgrade the macOS image version by @SimonSapin in #1418
- Remove the generic stream type from RouterResponse and ExecutionResponse by @Geal in #1420
- CI: run cargo test for all crates in the workspace by @SimonSapin in #1422
- Simplify boilerplate in the Rhai plugin by @SimonSapin in #1414
- Revert a
dbg!
that I forgot to remove in #1414 by @SimonSapin in #1424 - Remove experimental for references to rhai by @garypen in #1416
- Fix rustdoc warnings and deny them in
cargo xtask lint
by @SimonSapin in #1421 - Upgrade moka and crossbeam-* dependencies by @SimonSapin in #1419
- rewrite the caching API by @Geal in #1281
- small optimizations by @Geal in #1423
- fix: update scaffold to use 0.12.0 by @o0Ignition0o in #1431
- Defer: query plan changes by @Geal in #1182
- chore(deps): update dependency otel/opentelemetry-collector to v0.56.0 by @renovate in #1429
- remove the HTTP request from QueryPlannerRequest by @Geal in #1439
- Fix: Selection merge on non object field alias by @o0Ignition0o in #1432
- chore: Update
NEXT_CHANGELOG.md
formatting. by @abernix in #1442 - docs: updates some readme wording by @EverlastingBugstopper in #1445
- fix: update serialization format by @me-diru in #1391
- plugin new now takes a PluginInit struct (generic over config) by @garypen in #1446
- do not perform nested fetches if the parent one returned null by @Ty3uK in #1332
- feat(telemetry): add error section in custom attributes configuration by @bnjjj in #1443
- Configure Regex based CORS rules by @o0Ignition0o in #1444
- update buildstructor to 0.4.1 and add docs by @garypen in #1451
- Introspection support for includeDeprecated, isDeprecated, and deprecationReason by @SimonSapin in #1452
- helm repo for chart installation (#913) by @garypen in #1447
- Add
server.experimental_parser_recursion_limit
configuration by @SimonSapin in #1437 - release: v0.14.0 by @garypen in #1455
New Contributors
- @EverlastingBugstopper made their first contribution in #1445
- @me-diru made their first contribution in #1391
- @Ty3uK made their first contribution in #1332
Full Changelog: v0.12.0...v0.14.0