Hi everyone, we are trying to implement a caching on queries with Strapi and the graphql plugin.
Since the update, the Apollo dependencies does not rely on plugins anymore, instead, it asks to use Keyv (with KeyvAdapter and KeyvRedis)
(Configuring Cache Backends - Apollo GraphQL Docs)
Here is the code in config plugin.ts :
`import { KeyvAdapter } from “@apollo/utils.keyvadapter”;
import { ErrorsAreMissesCache, } from “@apollo/utils.keyvaluecache”;
import KeyvRedis from “@keyv/redis”;
import Keyv from ‘keyv’;
export default ({ env }) => ({
graphql: {
config: {
endpoint: “/graphql”,
shadowCRUD: true,
playgroundAlways: true,
depthLimit: 100,
amountLimit: 500,
defaultLimit: 10,
maxLimit: 500,
apolloServer: {
tracing: true,
introspection: true,
cache: new ErrorsAreMissesCache(
new KeyvAdapter(
new Keyv(new KeyvRedis(env(“REDIS_URL”))
)
)),
},
},
},`
The issue arise at build, where the env REDIS_URL is used, as strapi tries to connect immediately at build time, and not at runtime (we use strapi in a docker image). We seen lots of issues similar to this one but for v4 where Apollo did not use the same mecanisms. And GitHub - 10Life/strapi-plugin-advanced-cache-manager: A Cache Management for Strapi. seems to be out of date.
Versions are : keyv@5.1.2 @keyv/redis@3.0.1 @apollo/utils.keyvadapter@3.1.0 @apollo/utils.keyvaluecache3.1.0
This topic has been created from a Discord post (1301158402524713060) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord