Setup "graphql-codgen"

This commit is contained in:
schroda
2023-07-09 00:06:52 +02:00
parent 55c1c51edd
commit 1b4497db46
6 changed files with 2393 additions and 36 deletions

View File

@@ -1 +1,2 @@
.eslintrc.js
src/lib/graphql/generated

View File

@@ -2,7 +2,7 @@ module.exports = {
extends: ['airbnb', 'airbnb-typescript', 'prettier'],
plugins: ['@typescript-eslint', 'no-relative-import-paths', 'prettier', 'header'],
parserOptions: {
project: ['./tsconfig.json', './tools/scripts/tsconfig.json'],
project: ['./tsconfig.json', './tsconfig.node.json', './tools/scripts/tsconfig.json'],
},
overrides: [
{

37
gql_codegen.ts Normal file
View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
schema: 'http://localhost:4567/api/graphql',
documents: [
'src/lib/graphql/queries/**',
'src/lib/graphql/mutations/**',
'src/lib/graphql/subscriptions/**',
'src/lib/graphql/Fragments.ts',
],
ignoreNoDocuments: true,
generates: {
'src/lib/graphql/generated/graphql.ts': {
plugins: ['typescript', 'typescript-operations'],
config: {
namingConvention: {
typeNames: 'change-case-all#pascalCase',
transformUnderscore: true,
},
},
},
'src/lib/graphql/generated/apollo-helpers.ts': {
plugins: ['typescript-apollo-client-helpers'],
},
},
};
export default config;

View File

@@ -11,7 +11,8 @@
"build-zip": "cd build && rev=$(git rev-list HEAD --count) && echo r$rev > revision && zip -9 -r ../buildZip/Tachidesk-WebUI-r$rev *",
"lint": "eslint src --ext .ts,.tsx,.js,.jsx",
"createChangelog": "ts-node tools/scripts/createReleaseChanglog.ts",
"updateDeps": "yarn outdated && yarn upgrade && yarn syncyarnlock -s -k && yarn && git add package.json yarn.lock && git commit -m \"Update dependencies\""
"updateDeps": "yarn outdated && yarn upgrade && yarn syncyarnlock -s -k && yarn && git add package.json yarn.lock && git commit -m \"Update dependencies\"",
"gql:codegen": "graphql-codegen --config gql_codegen.ts"
},
"browserslist": {
"production": [
@@ -51,6 +52,10 @@
"vite-tsconfig-paths": "^4.2.1"
},
"devDependencies": {
"@graphql-codegen/cli": "^5.0.0",
"@graphql-codegen/client-preset": "^4.1.0",
"@graphql-codegen/typescript-apollo-client-helpers": "^2.2.6",
"@graphql-codegen/typescript-operations": "^4.0.1",
"@types/apollo-upload-client": "^17.0.2",
"@types/node": "^20.6.2",
"@types/react": "^18.2.21",

View File

@@ -8,6 +8,6 @@
},
"include": [
"vite.config.ts",
"vite.config.ts"
"gql_codegen.ts"
]
}

2380
yarn.lock

File diff suppressed because it is too large Load Diff