stopachka / stopablog-archived

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

Remove OneGraph proxy from the GitHub API #297

Closed dwwoelfel closed 1 year ago

dwwoelfel commented 1 year ago

Uses the relay compiler to generate next.js API routes by abusing the "persistConfig". The generated API routes will check that the variables are allowed and only allow the whitelisted variables to be used in the query.

Upgrades next.js and Relay to fix a pagination issue on the root page.

Now that we're not hitting OneGraph, it will require a GitHub token, which you can get from https://github.com/settings/tokens.

The token only needs the "public_repo" scope.

Once you have the token, add it to a new environment variable called GITHUB_TOKEN. Then you should be able to deploy.

A couple of things we lose without OneGraph:

  1. No fallback when the GitHub API goes down. We may be able to get that back with the next.js fetch cache. I also have an idea around using res.revalidate() which would let us set cache-control headers far into the future.
  2. No support for mutations (but you weren't using those anyway)

You can see it in action here: https://stopablog-next-test-jacv50mzh-dwwoelfel.vercel.app/post/296

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
stopablog ❌ Failed (Inspect) Mar 2, 2023 at 10:56PM (UTC)
stopachka commented 1 year ago

Appreciate this brother!