Skip to content

release: v1.4.0#2106

Merged
abernix merged 18 commits intomainfrom
1.4.0
Nov 15, 2022
Merged

release: v1.4.0#2106
abernix merged 18 commits intomainfrom
1.4.0

Conversation

@abernix
Copy link
Member

@abernix abernix commented Nov 15, 2022

🚀 Features

Add support for returning different HTTP status codes in Rhai (Issue #2023)

It is now possible to return different HTTP status codes when raising an exception in Rhai. You do this by providing an object map with two keys: status and message, rather than merely a string as was the case previously.

throw #{
    status: 403,
    message: "I have raised a 403"
};

This example will short-circuit request/response processing and return with an HTTP status code of 403 to the client and also set the error message accordingly.

It is still possible to return errors using the current pattern, which will continue to return HTTP status code 500 as previously:

throw "I have raised an error";

It is not currently possible to return a 200 status code using this pattern. If you try, it will be implicitly converted into a 500 error.

By @garypen in #2097

Add support for urlencode() / decode() in Rhai (Issue #2052)

Two new functions, urlencode() and urldecode() may now be used to URL-encode or URL-decode strings, respectively.

By @garypen in #2053

Experimental 🥼 External cache storage in Redis (PR #2024)

We are experimenting with introducing external storage for caches in the Router, which will provide a foundation for caching things like automated persisted queries (APQ) amongst other future-looking ideas. Our initial implementation supports a multi-level cache hierarchy, first attempting an in-memory LRU-cache, proceeded by a Redis Cluster backend.

As this is still experimental, it is only available as an opt-in through a Cargo feature-flag.

By @garypen and @Geal in #2024

Expose query_plan to ExecutionRequest in Rhai (PR #2081)

You can now read the query-plan from an execution request by accessing request.query_plan. Additionally, request.context also now supports the Rhai in keyword.

By @garypen in #2081

🐛 Fixes

Move error messages about nullifying into extensions (Issue #2071)

The Router was previously creating and returning error messages in errors when nullability rules had been triggered (e.g., when a non-nullable field was null, it nullifies the parent object). These are now emitted into a valueCompletion portion of the extensions response.

Adding those messages in the list of errors was potentially redundant and resulted in failures by clients (such as the Apollo Client error policy, by default) which would otherwise have expected nullified fields as part of normal operation execution. Additionally, the subgraph could already add such an error message indicating why a field was null which would cause the error to be doubled.

By @Geal in #2077

Fix Float input-type coercion for default values with values larger than 32-bit (Issue #2087)

A regression has been fixed which caused the Router to reject integers larger than 32-bits used as the default values on Float fields in input types.

In other words, the following will once again work as expected:

input MyInputType {
    a_float_input: Float = 9876543210
}

By @o0Ignition0o in #2090

Assume Accept: application/json when no Accept header is present Issue #1990)

The Accept header means */* when it is absent, and despite efforts to fix this previously, we still were not always doing the correct thing.

By @bnjjj in #2078

@skip and @include implementation for root-level fragment use (Issue #2072)

The @skip and @include directives are now implemented for both inline fragments and fragment spreads at the top-level of operations.

By @Geal in #2096

🛠 Maintenance

Use debian:bullseye-slim as our base Docker image (PR #2085)

A while ago, when we added compression support to the router, we discovered that the Distroless base-images we were using didn't ship with a copy of libz.so.1. We addressed that problem by copying in a version of the library from the Distroless image (Java) which does ship it. While that worked, we found challenges in adding support for both aarch64 and amd64 Docker images that would make it less than ideal to continue using those Distroless images.

Rather than persist with this complexity, we've concluded that it would be better to just use a base image which ships with libz.so.1, hence the change to debian:bullseye-slim. Those images are still quite minimal and the resulting images are similar in size.

By @garypen in #2085

Update apollo-parser to v0.3.2 (PR #2103)

This updates our dependency on our apollo-parser package which brings a few improvements, including more defensive parsing of some operations. See its CHANGELOG in the apollo-rs repository for more details.

By @abernix in #2103

📚 Documentation

Fix example helm show values command (PR #2088)

The helm show vaues command needs to use the correct Helm chart reference oci://ghcr.io/apollographql/helm-charts/router.

By @col in #2088

abernix and others added 18 commits November 9, 2022 14:25
Following up on:

- #2069 

By merging `main` back into `dev`.
implement caching in external storage for query plans, introspection and
APQ. This is done as a multi level cache, first in memory with LRU then
with a redis cluster backend. Since it is still experimental, it is
opt-in through a Cargo feature

Co-authored-by: Gary Pennington <gary@apollographql.com>
remove reference to the reqwest_tracing crate (that is not used anymore)
urlencode/decode strings from your rhai scripts.

fixes: #2052
close #1990

Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
#2020)

From our Slack thread, this PR: 

* Moves all examples into a matching subfolder (Rust-> `rust`, Rhai->
`rhai`)
* Adds a note about this change within the README in the examples
folder, as well as updated links
* Adds a new Rhai version of the `forbid_anonymous_operations` example
with unit test
* Updates the `Cargo.toml` to point to the new paths to avoid breaking
tests
* Updates each sample README to point to correct (now nested) path to
the demo supergraph file
### Fix `Float` input-type coercion for default values with values
larger than 32-bits ([Issue
#2087](#2087))

A regression has been fixed which caused the Router to reject integers
larger than 32-bits used as the default values on `Float` fields in
input types.

In other words, the following will once again work as expected:

```graphql
input MyInputType {
    a_float_input: Float = 9876543210
}
```

By [@o0Ignition0o](https://github.com/o0Ignition0o) in
#2090

Fixes #2087

Co-authored-by: Jesse Rosenberger <git@jro.cc>
This is a tiny PR but I think it's a valid fix. 

When I tried to run `helm show values apollographql/router` as suggested
in the README I got the error `Error: repo apollographql not found`.

I believe the command should actually be `helm show values
oci://ghcr.io/apollographql/helm-charts/router` which works as expected
for me.
)

Fix #2072

`@skip` and `@include` were not implemented for inline fragments and
fragment spreads on top level operations

Co-authored-by: Bryn Cooke <BrynCooke@gmail.com>
also:

 - cleanup dockerfiles so that we don't do binary copying between images
 - change base image from distroless to debian:bullseye-slim
 - unify 3 dockerfiles into 2

note: we no longer build "debug" images because the base image is now a
"debug" image (i.e.: it provides a shell we can use for investigating
issues). The image has grown by about 50%, but I think it's a reasonable
compromise to get away from the `libz.so.1` hackery.

Co-authored-by: Jesse Rosenberger <git@jro.cc>
Add unit tests for all rhai `request` and `response` accessors.

If a test fails, you'll see something like:

thread 'plugins::rhai::tests::it_can_process_supergraph_request'
panicked at 'test failed:
ErrorInFunctionCall("process_supergraph_request", "",
ErrorRuntime("query: expected: #{\"first\": 1}, actual: #{\"first\":
2}", 60:9), none)', apollo-router/src/plugins/rhai.rs:1749:16

Which is telling you why the rhai script failed (expected != actual) and
where it failed: functiona name, line number character offset. That
should be enough to figure out what the problem is.

also:
 - add support for reading the query_plan from an ExecutionRequest
 - add contains function for context
enhance the existing rhai error handling implementation so that specific
status codes can be set.

The change is fully backwards compatible (i.e.: the existing method
still works), but if a user wishes to specify the HTTP status code set
in the client response, they need only `throw` an objectmap as per the
examples in NEXT_CHANGELOG.md.

fixes: #2023
Fix #2071

Adding them in the list of errors was potentially redundant (subgraph
can already add an error message indicating why a field is null) and
could be treated as a failure by clients, while nullifying fields is a
part of normal operation. We still add the messages in extensions so
clients can easily debug why parts of the response were removed

Co-authored-by: Jesse Rosenberger <git@jro.cc>
This updates our dependency on our `apollo-parser` package which brings a few improvements, including more defensive parsing of some operations.  See its CHANGELOG in [the `apollo-rs` repository](https://github.com/apollographql/apollo-rs/blob/main/crates/apollo-parser/CHANGELOG.md#032---2022-11-15) for more details on what's included in the v0.3.2 release.
This prepares for the v1.4.0 by:

- Bump versions to v1.4.0
- Update license file
- Straight copy of `NEXT_CHANGELOG.md` to `CHANGELOG.md`
- CHANGELOG.md editorial prior to 1.4.0 release.

Co-authored-by: Jeremy Lempereur <jeremy.lempereur@gmail.com>
Copy link
Contributor

@o0Ignition0o o0Ignition0o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

federation-version-support.mdx doesn't need to be updated because it states:

    <tr>
        <td>
            v1.2.1 and later (<a href="https://github.com/apollographql/router/releases">see latest releases</a>)
        </td>
        <td>
            2.1.4
        </td>
    </tr>

@abernix abernix merged commit 518efbe into main Nov 15, 2022
@abernix abernix deleted the 1.4.0 branch March 29, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants