Skip to content

Commit e9d6379

Browse files
committed
refactor: graphql codegen
Signed-off-by: Adam Setch <[email protected]>
1 parent be7799a commit e9d6379

File tree

11 files changed

+39204
-165
lines changed

11 files changed

+39204
-165
lines changed

.gitignore

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,12 @@ build/
55
# Dependency directories
66
node_modules/
77

8+
# Generated GraphQL Files
9+
schema.graphql
10+
811
# Coverage directory used by tools like istanbul
912
coverage
1013
*.lcov
1114

12-
# Logs
13-
logs
14-
*.log
15-
npm-debug.log*
16-
17-
# Optional npm cache directory
18-
.npm
19-
20-
# Temporary folders
21-
tmp/
22-
temp/
23-
2415
# Mac Files
2516
.DS_Store

codegen.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { CodegenConfig } from '@graphql-codegen/cli';
2+
3+
const config: CodegenConfig = {
4+
overwrite: true,
5+
schema: 'https://docs.github.com/public/fpt/schema.docs.graphql',
6+
documents: [
7+
'src/renderer/utils/api/**/*.ts',
8+
'!src/renderer/utils/api/graphql/generated/**',
9+
'!src/renderer/utils/api/**/*.test.ts',
10+
],
11+
generates: {
12+
'src/renderer/utils/api/graphql/generated/': {
13+
preset: 'client',
14+
config: {
15+
documentMode: 'string',
16+
},
17+
},
18+
// 'src/renderer/utils/api/graphql/generated/schema.graphql': {
19+
// plugins: ['schema-ast'],
20+
// config: {
21+
// includeDirectives: true,
22+
// },
23+
// },
24+
},
25+
};
26+
27+
export default config;

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build:main": "webpack --config ./config/webpack.config.main.prod.ts",
1010
"build:preload": "webpack --config ./config/webpack.config.preload.prod.ts",
1111
"build:renderer": "webpack --config ./config/webpack.config.renderer.prod.ts",
12-
"watch": "concurrently --names \"main,preload,renderer\" --prefix-colors \"blue,magenta,green\" \"pnpm watch:main\" \"pnpm watch:preload\" \"pnpm watch:renderer\"",
12+
"watch": "concurrently --names \"main,preload,renderer,codegen\" --prefix-colors \"blue,magenta,green,cyan\" \"pnpm watch:main\" \"pnpm watch:preload\" \"pnpm watch:renderer\" \"pnpm watch:codegen\"",
13+
"watch:codegen": "pnpm codegen --watch",
1314
"watch:main": "webpack --watch --config ./config/webpack.config.main.base.ts",
1415
"watch:preload": "webpack --watch --config ./config/webpack.config.preload.base.ts",
1516
"watch:renderer": "webpack --watch --config ./config/webpack.config.renderer.base.ts",
@@ -20,7 +21,8 @@
2021
"lint": "biome check --fix",
2122
"test": "jest",
2223
"start": "electron . --enable-logging",
23-
"prepare": "husky"
24+
"prepare": "husky",
25+
"codegen": "graphql-codegen --config codegen.ts"
2426
},
2527
"engines": {
2628
"node": ">=22"
@@ -74,9 +76,14 @@
7476
"react-router-dom": "7.8.2"
7577
},
7678
"devDependencies": {
79+
"@0no-co/graphqlsp": "1.15.0",
7780
"@biomejs/biome": "2.2.4",
7881
"@discordapp/twemoji": "16.0.1",
7982
"@electron/notarize": "3.1.0",
83+
"@graphql-codegen/cli": "6.0.0",
84+
"@graphql-codegen/client-preset": "5.0.0",
85+
"@graphql-codegen/schema-ast": "5.0.0",
86+
"@parcel/watcher": "2.5.1",
8087
"@primer/css": "22.0.2",
8188
"@primer/octicons-react": "19.18.0",
8289
"@primer/primitives": "11.1.0",
@@ -102,7 +109,7 @@
102109
"electron": "38.1.0",
103110
"electron-builder": "26.0.12",
104111
"final-form": "5.0.0",
105-
"graphql-tag": "2.12.6",
112+
"graphql": "16.11.0",
106113
"html-webpack-plugin": "5.6.4",
107114
"husky": "9.1.7",
108115
"jest": "30.1.3",
@@ -138,4 +145,4 @@
138145
"*": "biome check --fix --no-errors-on-unmatched",
139146
"*.{js,ts,tsx}": "pnpm test --findRelatedTests --passWithNoTests --updateSnapshot"
140147
}
141-
}
148+
}

0 commit comments

Comments
 (0)