Adding experimental_cache as a Cargo feature

I have been trying to use the experimental_cache feature, specifically the external caching with redis.

In the documentation (Caching in the Apollo Router - Apollo GraphQL Docs) it states that “it can be tested by building a custom Router binary, with the Cargo feature experimental_cache”.

I have taken this to mean that it should be added to Cargo.toml like this:

[features]
experimental_cache = []

With configuration like this:

supergraph:
  apq:
    experimental_cache:
      in_memory:
        limit: 512
      redis:
        urls: ["redis://..."]
  query_planning:
    experimental_cache:
      in_memory:
        limit: 512
      redis:
        urls: ["redis://..."]

However, doing this gives me the error:

ERROR configuration had errors: 
1. /supergraph/apq/experimental_cache

supergraph:
  apq:
    experimental_cache:
┌       in_memory:
|         limit: 512
|       redis:
|         urls: ["redis://..."]
└-----> Additional properties are not allowed ('redis' was unexpected)

2. /supergraph/query_planning/experimental_cache

        limit: 512
      redis:
        urls: ["redis://..."]
  query_planning:
    experimental_cache:
┌       in_memory:
|         limit: 512
|       redis:
|         urls: ["redis://..."]
└-----> Additional properties are not allowed ('redis' was unexpected)
2023-01-19T14:03:27.064894Z ERROR no valid configuration was supplied
Error: no valid configuration was supplied

I’m pretty sure I need additional configuration in order to use the redis part (the experimental_cache works fine without it), but it is not described in the documentation.

If someone could point me in the right direction it would be greatly appreciated.

Router version is 1.6.0

Hi :wave:

We’re actually working on the 1.9.0 release of the Apollo Router that will add this all to the standard router binary. This will remove the need to build the router yourself and should be ready very soon.

Hi, thank you for this answer, but I actually found out were I went wrong. It was, as expected, because I have no understanding of rust :smiley:

Adding the feature as: “apollo-router = { version = “1.6.0”, features = [“experimental_cache”] }” under dependencies instead of just under features works.

1 Like

Great! We also just shipped the version of the Apollo Router where you don’t have to build it yourself. You can read about it [here].(router/CHANGELOG.md at dev · apollographql/router · GitHub)