Next, it adds support for proper support for Unchanged caches through some modifications to the cache key calculation
Lastly, more tests
Persisted Queries
This one is relatively straightforward, but this adds support to cache Persisted Queries through the same mechanism as before. The only callout here is due to how the IDs are formatted for PQs, the entire response is currently being cached, although there is some functionality here that's important to note as well.
As the current PQ system returns a signed URL that expires in an hour, this also adds support to store PQs in Redis. The PQ manifests are downloaded via Relay, and then uploaded into the cache compressed using zlib to avoid crushing the cache.
This behavior may be something we want to support natively, but is outside of scope for this specific PR.
Unchanged support
The Uplink API will, given the ifAfterId parameter being passed, send back an Unchanged type to the requestor. This has a side effect whereby a router would continuously see that it has a "new" schema to reload (or PQs), and have to calculate whether to update or not.
By supporting Unchanged, we can mitigate that.
This is done through updating the cache key calculation to accept an arbitrary number of arguments, and then sha256 hashing them as part of the end of the key. This is primarily used to insert the arguments as the remaining entries, meaning that the cache entry is unique per the specific ifAfterIdand the graphRef/apiKey, such that it shouldn't cause collisions further than that.
Tests
Called out by a few customers (and myself), this adds more tests to the repo and we have nearly all files with some level of testing. The config will eventually need testing, but feels safe enough as-is. Code coverage can certainly be improved, however.
This one is a little meatier than expected, but covers three big areas:
Unchanged
caches through some modifications to the cache key calculationPersisted Queries
This one is relatively straightforward, but this adds support to cache Persisted Queries through the same mechanism as before. The only callout here is due to how the IDs are formatted for PQs, the entire response is currently being cached, although there is some functionality here that's important to note as well.
As the current PQ system returns a signed URL that expires in an hour, this also adds support to store PQs in Redis. The PQ manifests are downloaded via Relay, and then uploaded into the cache compressed using
zlib
to avoid crushing the cache.This behavior may be something we want to support natively, but is outside of scope for this specific PR.
Unchanged
supportThe Uplink API will, given the
ifAfterId
parameter being passed, send back anUnchanged
type to the requestor. This has a side effect whereby a router would continuously see that it has a "new" schema to reload (or PQs), and have to calculate whether to update or not.By supporting
Unchanged
, we can mitigate that.This is done through updating the cache key calculation to accept an arbitrary number of arguments, and then sha256 hashing them as part of the end of the key. This is primarily used to insert the arguments as the remaining entries, meaning that the cache entry is unique per the specific
ifAfterId
and the graphRef/apiKey, such that it shouldn't cause collisions further than that.Tests
Called out by a few customers (and myself), this adds more tests to the repo and we have nearly all files with some level of testing. The config will eventually need testing, but feels safe enough as-is. Code coverage can certainly be improved, however.