diff --git a/website/src/pages/docs/features/automatic-persisted-queries.mdx b/website/src/pages/docs/features/automatic-persisted-queries.mdx index c355c44177..657f432809 100644 --- a/website/src/pages/docs/features/automatic-persisted-queries.mdx +++ b/website/src/pages/docs/features/automatic-persisted-queries.mdx @@ -119,6 +119,38 @@ server.listen(4000, () => { For external stores the `set` and `get` properties on the store can also return a `Promise`. + + In production, it's recommended to capture the errors from any store that could stop functioning. + Instead of raising an error, returning undefined or null will allow the server to continue to + respond to requests if the store goes down. + + ```ts filename="Automatic Persisted Operations with a redis store" {16} + import Keyv from "keyv"; + + const store = new Keyv("redis://user:pass@localhost:6379"); + + useAPQ({ + store: { + async get(key) { + try { + return await store.get(key); + } catch(e) { + console.error(`Error while fetching the operation: ${key}`, e); + } + }, + async set(key, value) { + try { + return await store.set(key, value); + } catch(e) { + console.error(`Error while saving the operation: ${key}`, e); + } + } + } + }) + ``` + + + ## Configure Error responses By default, responses for missing or mismatching query will include `extensions` property with HTTP