stopachka / stopablog-archived

[Archive] The blog, powered by OneGraph : )
https://www.stopa.io
6 stars 1 forks source link

Fallback on error #280

Closed dwwoelfel closed 3 years ago

dwwoelfel commented 3 years ago

Sets a flag when we persist the query that will cause OneGraph to fallback to the last successful response In case a persisted query returns an error.

This will prevent any rate-limit errors from taking down the blog.

A bit on how it works, if you're interested:

When a query is persisted with fallbackOnError set to true and the query executes successfully , then OneGraph will store the result in a google storage bucket. The bucket is set to auto-delete items after 30 days. If the persisted query executes later with an error in the errors field, then OneGraph will fetch the result of the successful execution from storage and return that instead.

We add a little bit of data to the extensions field so that you can tell if the fallback was used and why. The result looks something like this:

{
  "data": {
    "npm": {
      "package": {
        "name": "relay",
        "id": "relay",
        "distTags": {
          "latest": {
            "versionString": "0.8.0-1"
          }
        }
      }
    }
  },
  "extensions": {
    "persistedQueryFallback": true,
    "lastModified": "2021-06-15T02:29:28-00:00",
    "errors": [
      {
        "message": "Whoops!",
        "path": [
          "npm",
          "package"
        ]
      }
    ]
  }
}
vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/stopa/stopablog/4FqCKuKjmqMiSnhHNXXC9bnqYpeL
✅ Preview: Failed