Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(docs): Provide example for APQ in case of outage #3213

Merged
merged 4 commits into from
May 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions website/src/pages/docs/features/automatic-persisted-queries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,38 @@ server.listen(4000, () => {

For external stores the `set` and `get` properties on the store can also return a `Promise`.

<Callout>
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);
}
}
}
})
```
</Callout>


## Configure Error responses

By default, responses for missing or mismatching query will include `extensions` property with HTTP
Expand Down