Apollo Server persisted queries storage location not exposed in configuration
0 reputation · 08 May 2023, 15:16 UTC
0 reputation · 08 May 2023, 15:16 UTC
Apollo Server 3.x supports persisted queries, which are cached in Redis by default.
The server configuration does not expose which Redis instance is used for this storage, so logs only report generic 'persisted query not found' messages without indicating the underlying storage cause.
Because the storage endpoint is implicit, operators cannot reliably correlate deployment failures with cache eviction, permission checks, or misconfiguration, and the documentation provides no explicit flag to toggle persistence storage.
Which Redis endpoint is configured for persisted query storage in a given Apollo Server deployment?
How can operators verify the storage location without modifying the configuration?
What log patterns indicate a storage-related failure versus a permission check?
37275 reputation · 08 May 2023, 21:40 UTC
Apollo Server 3.x does not use Redis by default for Automatic Persisted Queries (APQ). The built-in default is an in-memory LRU cache. Redis (or any other backend) is only used when the application explicitly provides a KeyValueCache implementation via the persistedQueries.cache option in the ApolloServer constructor. There is no REDIS_URL environment variable read by Apollo Server itself.
The question states "Apollo Server 3.x supports persisted queries, which are cached in Redis by default." This is false. The default APQ cache is InMemoryLRUCache from @apollo/utils.keyvaluecache. Any Redis usage comes from application code that constructs a Redis-backed KeyValueCache (commonly via @apollo/utils.keyvaluecache's RedisCache or a custom wrapper around ioredis/node-redis) and passes it to new ApolloServer({ persistedQueries: { cache: myRedisCache } }).
Because the cache is supplied by application code, the Redis endpoint (if any) is visible only in that code or its configuration. Steps that do not require changing the running configuration:
persistedQueries: { cache: ... } in the ApolloServer options. The cache instance will reveal the Redis client construction (e.g., new Redis(process.env.REDIS_URL), createClient({ url: ... }), or a connection pool).REDIS_URL, CACHE_REDIS_URL, or similar, that value (redacted to host:port/db) identifies the endpoint. Do not log full URLs with credentials.CLIENT LIST or CLIENT INFO and match the Apollo Server process name, lib name (ioredis, node-redis), and source IP/port to the Apollo process. This confirms which Redis instance the Apollo process is connected to without using KEYS (which is O(N) and blocking).Error-level logs from the Redis client library (e.g., Redis connection error: ECONNREFUSED, READONLY You can't write against a read only replica, NOPERM ACL). These are separate from the APQ "not found" message.DEBUG=apollo-server:cache namespace that emits SET/GET/EXPIRE traces. The underlying Redis client may honor its own debug flags (e.g., DEBUG=ioredis:* or DEBUG=redis:*), but enabling them requires a process restart and changes runtime behavior, so it does not meet "without modifying configuration."persistedQueries.cache initializer.CLIENT LIST on the candidate Redis instance and confirm the Apollo process appears as a connected client.persistedQueries.cache provided), there is no Redis endpoint for APQ — the cache lives in the Node process and is lost on restart.If the codebase is unavailable, the single detail that resolves the question is: the exact persistedQueries.cache initializer code or the redacted connection string it uses (host:port/db, no password).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.