Skip to content

Commit 347cbb9

Browse files
authored
Remove onegraph proxy and hit github directly (#40)
* remove onegraph proxy and hit github directly * update readme * cleanup * cleanup
1 parent 1cc2484 commit 347cbb9

34 files changed

+28794
-247080
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# production
1212
/build
1313
src/__generated__
14+
src/pages/api/__generated__
1415

1516
# misc
1617
.DS_Store

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ singleQuote: true
22
trailingComma: "all"
33
bracketSpacing: false
44
jsxBracketSameLine: true
5+
bracketSameLine: true
56
printWidth: 80

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ Copy `/.env.example` to `/.env` and set the following environment variables.
2020

2121
### Environment variables
2222

23-
| Environment Variable | Description |
24-
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25-
| `OG_GITHUB_TOKEN` | A server-side access token created on OneGraph, used as the default auth for the persisted queries that will fetch the issues. To create a new one, go the "Server-side Auth" tab in the [OneGraph dashboard](https://www.onegraph.com/dashboard) for your app, click the "Create Token" button, and add GitHub to the services. Keep this token safe, because it has access to your GitHub data. |
26-
| `OG_DASHBOARD_ACCESS_TOKEN` | An API token that allows you to create persisted queries on OneGraph. Go to the "Persisted queries" tab on the OneGraph dashboard, scroll down, and click "Create token". This will create a scoped token for your app that can create persisted queries on your behalf. |
27-
| `NEXT_PUBLIC_ONEGRAPH_APP_ID` | The id of your OneGraph app. You can get this from the [OneGraph dashboard](https://www.onegraph.com/dashboard) |
28-
| `NEXT_PUBLIC_TITLE` | The title of your site |
29-
| `NEXT_PUBLIC_DESCRIPTION` | A short description of your site. |
30-
| `NEXT_PUBLIC_GITHUB_REPO_OWNER` | The owner of the repo that we should pull issues from (e.g. linus in linus/oneblog). If you're using the Vercel deploy button, you don't need to provide this. |
31-
| `NEXT_PUBLIC_GITHUB_REPO_NAME` | The name of the repo that we should pull issues from (e.g. oneblog in linus/oneblog). If you're using the Vercel deploy button, you don't need to provide this. |
23+
| Environment Variable | Description |
24+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
25+
| `GITHUB_TOKEN` | A GitHub token, which you can get from https://github.com/settings/tokens. The token only needs the "public_repo" scope. |
26+
| `NEXT_PUBLIC_TITLE` | The title of your site |
27+
| `NEXT_PUBLIC_DESCRIPTION` | A short description of your site. |
28+
| `NEXT_PUBLIC_GITHUB_REPO_OWNER` | The owner of the repo that we should pull issues from (e.g. linus in linus/oneblog). If you're using the Vercel deploy button, you don't need to provide this. |
29+
| `NEXT_PUBLIC_GITHUB_REPO_NAME` | The name of the repo that we should pull issues from (e.g. oneblog in linus/oneblog). If you're using the Vercel deploy button, you don't need to provide this. |
3230

3331
### Setup relay
3432

@@ -73,8 +71,6 @@ The project will load at [http://localhost:3000](http://localhost:3000).
7371

7472
The project comes with setups for deploying to Google's Firebase, Zeit's Now, Netlify, and Fly.io.
7573

76-
For each of these, you'll have to add the site that you're deploying to on the CORS origins on the OneGraph dashboard.
77-
7874
### Deploy with Vercel
7975

8076
Use the deploy button to set up a new repo:
@@ -122,7 +118,7 @@ The `persistFunction` for the relay compiler is set to `/scripts/persistQuery.js
122118

123119
That function will parse the query and pull out the `@persistedQueryConfiguration` directive to determine if any auth should be stored alongside the query. In the changelog, the queries for fetching posts use persisted auth, but the mutations for adding reactions require the user to log in with OneGraph and use their auth.
124120

125-
The `@persistedQueryConfiguration` directive is stripped from the query and it is uploaded to OneGraph via a GraphQL mutation. Then the id for the persisted query is returned from the function. Relay stores the id in its generated file and it's used the next time the query is sent to the server.
121+
The `@persistedQueryConfiguration` directive is stripped from the query and a next api route is generated to execute the query.
126122

127123
### Server
128124

package.json

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,39 @@
66
"@tippyjs/react": "4.1.0",
77
"@vercel/fetch-retry": "^5.0.3",
88
"date-fns": "2.9.0",
9-
"email-reply-parser": "^1.2.1",
9+
"email-reply-parser": "1.2.6",
1010
"feed": "^4.0.0",
1111
"gif-stream": "^1.1.0",
12-
"grommet": "2.15.0",
12+
"grommet": "2.30.0",
1313
"grommet-icons": "^4.4.0",
1414
"inline-css": "^2.5.1",
1515
"intersection-observer": "^0.11.0",
1616
"lower-case": "^2.0.1",
1717
"neuquant": "^1.0.2",
18-
"next": "^10.0.6",
18+
"next": "^13.2.3",
1919
"node-fetch": "^2.6.0",
2020
"onegraph-auth": "^3.0.0",
2121
"pixel-stream": "^1.0.3",
22-
"react": "0.0.0-experimental-94c0244ba",
23-
"react-dom": "0.0.0-experimental-94c0244ba",
22+
"react": "18.2.0",
23+
"react-dom": "18.2.0",
2424
"react-intersection-observer": "^8.28.5",
25+
"react-is": "^18.2.0",
2526
"react-markdown": "^4.3.1",
2627
"react-player": "^2.6.2",
27-
"react-relay": "0.0.0-experimental-183bdd28",
28-
"relay-runtime": "^10.0.1",
28+
"react-relay": "14.1.0",
29+
"relay-runtime": "14.1.0",
2930
"scriptjs": "^2.5.9",
3031
"sentence-case": "^3.0.3",
3132
"sitemap": "^6.3.2",
32-
"styled-components": "^5.0.0"
33-
},
34-
"resolutions": {
35-
"react": "0.0.0-experimental-94c0244ba",
36-
"react-dom": "0.0.0-experimental-94c0244ba"
33+
"styled-components": "^5.3.8"
3734
},
3835
"scripts": {
3936
"dev": "next",
4037
"start": "next",
41-
"build": "yarn ensure-publish-label && yarn relay && next build",
38+
"build": "yarn relay && next build",
4239
"start:prod": "NODE_ENV=production node build/server.js",
43-
"relay": "relay-compiler --src ./src --schema ./schema.graphql --persistFunction scripts/persistQuery.js",
44-
"relay:clean": "rm -r src/__generated__",
40+
"relay": "node scripts/relay-compiler.js",
41+
"relay:clean": "rm -r src/__generated__ src/pages/api/__generated__",
4542
"flow": "flow",
4643
"fetch-schema": "node scripts/fetchSchema.js --path schema.graphql",
4744
"ensure-publish-label": "node scripts/ensurePublishLabel.js",
@@ -52,23 +49,22 @@
5249
"extends": "react-app"
5350
},
5451
"browserslist": {
55-
"production": [
56-
">0.2%",
57-
"not dead",
58-
"not op_mini all"
59-
],
52+
"production": [">0.2%", "not dead", "not op_mini all"],
6053
"development": [
6154
"last 1 chrome version",
6255
"last 1 firefox version",
6356
"last 1 safari version"
6457
]
6558
},
6659
"devDependencies": {
60+
"@babel/core": "^7.21.0",
6761
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
6862
"@babel/preset-flow": "^7.0.0",
63+
"@babel/runtime": "^7.21.0",
6964
"babel-eslint": "10.x",
7065
"babel-plugin-macros": "^2.6.1",
71-
"babel-plugin-relay": "^8.0.0",
66+
"babel-plugin-relay": "14.1.0",
67+
"dotenv": "^16.0.3",
7268
"eslint": "6.x",
7369
"eslint-config-react-app": "^5.2.1",
7470
"eslint-plugin-flowtype": "4.x",
@@ -78,11 +74,11 @@
7874
"eslint-plugin-react-hooks": "2.x",
7975
"flow-bin": "^0.133.0",
8076
"flow-typed": "^3.2.1",
77+
"get-port": "^6.1.2",
8178
"graphql": "^14.4.2",
8279
"prettier": "^2.1.2",
83-
"razzle": "^3.0.0",
84-
"relay-compiler": "^8.0.0",
85-
"relay-test-utils": "^8.0.0",
80+
"relay-compiler": "14.1.0",
81+
"relay-test-utils": "14.1.0",
8682
"require-times": "^1.1.0",
8783
"source-map-explorer": "^2.0.1"
8884
},

relay.config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"src": "./src/",
3+
"language": "flow",
4+
"schema": "./schema.graphql",
5+
"exclude": ["**/node_modules/**", "**/__generated__/**"],
6+
"schemaExtensions": ["./src/"],
7+
"persistConfig": {
8+
"url": "http://localhost:2999"
9+
}
10+
}

0 commit comments

Comments
 (0)