Skip to content

Commit e4a8482

Browse files
feat: Added support for generating type definitions from the graphql schemas
1 parent a477265 commit e4a8482

22 files changed

+9530
-5767
lines changed

.eslintrc

Lines changed: 108 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,115 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"parserOptions": {
5-
"project": true,
6-
"tsconfigRootDir": ".",
7-
"sourceType": "module"
8-
},
9-
"plugins": ["@typescript-eslint", "sonarjs", "jest", "prettier"],
10-
"extends": [
11-
"eslint:recommended",
12-
"airbnb-base",
13-
"airbnb-typescript/base",
14-
"plugin:jest/recommended",
15-
"plugin:sonarjs/recommended",
16-
"plugin:@typescript-eslint/strict-type-checked",
17-
"plugin:@typescript-eslint/stylistic-type-checked",
18-
"plugin:prettier/recommended"
19-
],
20-
"ignorePatterns": ["**/node_modules/**", "dist/**", "src/entity/**"],
21-
"rules": {
22-
// These rules are for reference only.
23-
//#region eslint
24-
"class-methods-use-this": "off",
25-
// https://github.com/typescript-eslint/typescript-eslint/issues/1277
26-
"consistent-return": "off",
27-
"func-names": "off",
28-
"max-len": ["error", { "code": 140, "ignoreTemplateLiterals": true, "ignoreUrls": true }],
29-
"newline-per-chained-call": "off",
30-
"no-await-in-loop": "off",
31-
"no-continue": "off",
32-
// https://github.com/airbnb/javascript/issues/1342
33-
"no-param-reassign": ["error", { "props": false }],
34-
// https://github.com/airbnb/javascript/issues/1271
35-
// https://github.com/airbnb/javascript/blob/fd77bbebb77362ddecfef7aba3bf6abf7bdd81f2/packages/eslint-config-airbnb-base/rules/style.js#L340-L358
36-
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
37-
"no-underscore-dangle": ["error", { "allow": ["_id"] }],
38-
"no-void": ["error", { "allowAsStatement": true }],
39-
"object-curly-newline": "off",
40-
"spaced-comment": ["error", "always", { "line": { "markers": ["/", "#region", "#endregion"] } }],
41-
//#endregion
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"project": true,
6+
"tsconfigRootDir": ".",
7+
"sourceType": "module"
8+
},
9+
"plugins": ["@typescript-eslint", "sonarjs", "jest", "prettier"],
10+
"extends": [
11+
"eslint:recommended",
12+
"airbnb-base",
13+
"airbnb-typescript/base",
14+
"plugin:jest/recommended",
15+
"plugin:sonarjs/recommended",
16+
"plugin:@typescript-eslint/strict-type-checked",
17+
"plugin:@typescript-eslint/stylistic-type-checked",
18+
"plugin:prettier/recommended"
19+
],
20+
"ignorePatterns": ["**/node_modules/**", "dist/**", "*.graphql"],
21+
"rules": {
22+
// These rules are for reference only.
23+
//#region eslint
24+
"class-methods-use-this": "off",
25+
// https://github.com/typescript-eslint/typescript-eslint/issues/1277
26+
"consistent-return": "off",
27+
"func-names": "off",
28+
"max-len": ["error", { "code": 140, "ignoreTemplateLiterals": true, "ignoreUrls": true }],
29+
"newline-per-chained-call": "off",
30+
"no-await-in-loop": "off",
31+
"no-continue": "off",
32+
// https://github.com/airbnb/javascript/issues/1342
33+
"no-param-reassign": ["error", { "props": false }],
34+
// https://github.com/airbnb/javascript/issues/1271
35+
// https://github.com/airbnb/javascript/blob/fd77bbebb77362ddecfef7aba3bf6abf7bdd81f2/packages/eslint-config-airbnb-base/rules/style.js#L340-L358
36+
"no-restricted-syntax": ["error", "ForInStatement", "LabeledStatement", "WithStatement"],
37+
"no-underscore-dangle": ["error", { "allow": ["_id"] }],
38+
"no-void": ["error", { "allowAsStatement": true }],
39+
"object-curly-newline": "off",
40+
"spaced-comment": [
41+
"error",
42+
"always",
43+
{ "line": { "markers": ["/", "#region", "#endregion"] } }
44+
],
45+
//#endregion
4246

43-
//#region import
44-
"import/extensions": ["error", "never"],
45-
// https://github.com/benmosher/eslint-plugin-import/issues/1753
46-
"import/named": "off",
47-
"import/no-default-export": "error",
48-
"import/order": [
49-
"error",
50-
{
51-
"groups": [["builtin", "external", "internal"]],
52-
"newlines-between": "always",
53-
"alphabetize": { "order": "asc", "caseInsensitive": true }
54-
}
55-
],
56-
"import/prefer-default-export": "off",
57-
//#endregion
47+
//#region import
48+
"import/extensions": ["error", "never"],
49+
// https://github.com/benmosher/eslint-plugin-import/issues/1753
50+
"import/named": "off",
51+
"import/no-default-export": "error",
52+
"import/order": [
53+
"error",
54+
{
55+
"groups": [["builtin", "external", "internal"]],
56+
"newlines-between": "always",
57+
"alphabetize": { "order": "asc", "caseInsensitive": true }
58+
}
59+
],
60+
"import/prefer-default-export": "off",
61+
//#endregion
5862

59-
//#region @typescript-eslint
60-
"@typescript-eslint/consistent-type-assertions": ["error", { "assertionStyle": "angle-bracket" }],
61-
"@typescript-eslint/lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
62-
"@typescript-eslint/naming-convention": [
63-
"error",
64-
{ "selector": "default", "format": ["strictCamelCase"] },
65-
{ "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE", "StrictPascalCase"] },
66-
// https://github.com/microsoft/TypeScript/issues/9458
67-
{
68-
"selector": "parameter",
69-
"modifiers": ["unused"],
70-
"format": ["strictCamelCase"],
71-
"leadingUnderscore": "allow"
72-
},
73-
{ "selector": "property", "format": null },
74-
{ "selector": "typeProperty", "format": null },
75-
{ "selector": "typeLike", "format": ["StrictPascalCase"] },
76-
{ "selector": "enumMember", "format": ["UPPER_CASE"] }
77-
],
78-
"@typescript-eslint/no-extraneous-class": "off",
79-
"@typescript-eslint/no-unsafe-member-access": "off",
80-
//#endregion
63+
//#region @typescript-eslint
64+
"@typescript-eslint/consistent-type-assertions": [
65+
"error",
66+
{ "assertionStyle": "angle-bracket" }
67+
],
68+
"@typescript-eslint/lines-between-class-members": [
69+
"error",
70+
"always",
71+
{ "exceptAfterSingleLine": true }
72+
],
73+
"@typescript-eslint/naming-convention": [
74+
"error",
75+
{ "selector": "default", "format": ["strictCamelCase"] },
76+
{ "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE", "StrictPascalCase"] },
77+
// https://github.com/microsoft/TypeScript/issues/9458
78+
{
79+
"selector": "parameter",
80+
"modifiers": ["unused"],
81+
"format": ["strictCamelCase"],
82+
"leadingUnderscore": "allow"
83+
},
84+
{ "selector": "property", "format": null },
85+
{ "selector": "typeProperty", "format": null },
86+
{ "selector": "typeLike", "format": ["StrictPascalCase"] },
87+
{ "selector": "enumMember", "format": ["UPPER_CASE"] }
88+
],
89+
"@typescript-eslint/no-extraneous-class": "off",
90+
"@typescript-eslint/no-unsafe-member-access": "off",
91+
//#endregion
8192

82-
//#region sonarjs
83-
"sonarjs/no-duplicate-string": "off",
84-
"sonarjs/cognitive-complexity": ["error", 25],
85-
//#endregion
93+
//#region sonarjs
94+
"sonarjs/no-duplicate-string": "off",
95+
"sonarjs/cognitive-complexity": ["error", 25],
96+
//#endregion
8697

87-
"prettier/prettier": [
88-
"error",
89-
{
90-
"singleQuote": true,
91-
"endOfLine": "auto"
92-
}
93-
],
98+
"prettier/prettier": [
99+
"error",
100+
{
101+
"singleQuote": true,
102+
"endOfLine": "auto"
103+
}
104+
],
94105

95-
"quotes": [
96-
2,
97-
"single",
98-
{
99-
"avoidEscape": true,
100-
"allowTemplateLiterals": true
101-
}
102-
]
103-
}
106+
"quotes": [
107+
2,
108+
"single",
109+
{
110+
"avoidEscape": true,
111+
"allowTemplateLiterals": true
112+
}
113+
]
114+
}
104115
}

.vscode/settings.json

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
11
{
2-
"scss.lint.unknownAtRules": "ignore",
3-
"files.eol": "\n",
4-
"editor.defaultFormatter": "esbenp.prettier-vscode",
5-
"editor.formatOnSave": true,
6-
"editor.formatOnPaste": true,
7-
"editor.detectIndentation": true,
8-
"editor.fontLigatures": false,
9-
"editor.snippetSuggestions": "top",
10-
"editor.suggest.localityBonus": true,
11-
"editor.acceptSuggestionOnCommitCharacter": false,
12-
"editor.renderWhitespace": "boundary",
13-
"editor.codeActionsOnSave": {
14-
"source.fixAll.eslint": "explicit"
15-
},
16-
"editor.cursorSmoothCaretAnimation": "on",
17-
"editor.fontSize": 20,
18-
"editor.minimap.enabled": false,
19-
"editor.tabSize": 2,
2+
"scss.lint.unknownAtRules": "ignore",
3+
"files.eol": "\n",
4+
"editor.defaultFormatter": "esbenp.prettier-vscode",
5+
"editor.formatOnSave": true,
6+
"editor.formatOnPaste": true,
7+
"editor.detectIndentation": true,
8+
"editor.fontLigatures": false,
9+
"editor.snippetSuggestions": "top",
10+
"editor.suggest.localityBonus": true,
11+
"editor.acceptSuggestionOnCommitCharacter": false,
12+
"editor.renderWhitespace": "boundary",
13+
"editor.codeActionsOnSave": {
14+
"source.fixAll.eslint": "explicit"
15+
},
16+
"editor.cursorSmoothCaretAnimation": "on",
17+
"editor.fontSize": 30,
18+
"editor.minimap.enabled": false,
19+
"editor.tabSize": 2,
2020

21-
"files.trimTrailingWhitespace": true,
22-
"files.trimFinalNewlines": true,
21+
"files.trimTrailingWhitespace": true,
22+
"files.trimFinalNewlines": true,
2323

24-
"workbench.sideBar.location": "right",
24+
"workbench.sideBar.location": "right",
2525

26-
"javascript.updateImportsOnFileMove.enabled": "always",
26+
"javascript.updateImportsOnFileMove.enabled": "always",
2727

28-
"typescript.validate.enable": true,
28+
"typescript.validate.enable": true,
2929

30-
"files.autoSave": "off",
31-
"files.exclude": {
32-
"USE_GITIGNORE": true
33-
},
34-
"files.defaultLanguage": "{activeEditorLanguage}",
30+
"files.autoSave": "off",
31+
"files.exclude": {
32+
"USE_GITIGNORE": true
33+
},
34+
"files.defaultLanguage": "{activeEditorLanguage}",
3535

36-
"javascript.validate.enable": true, // Highligts the unused imports when true
37-
"editor.showUnused": true, // Highligts the unused imports when true
36+
"javascript.validate.enable": true, // Highligts the unused imports when true
37+
"editor.showUnused": true, // Highligts the unused imports when true
3838

39-
"search.exclude": {
40-
"**/node_modules": true,
41-
"**/bower_components": true,
42-
"**/*.code-search": true,
43-
"**/build": true,
44-
"**/.build": true
45-
},
39+
"search.exclude": {
40+
"**/node_modules": true,
41+
"**/bower_components": true,
42+
"**/*.code-search": true,
43+
"**/build": true,
44+
"**/.build": true
45+
},
4646

47-
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
47+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
4848

49-
"breadcrumbs.enabled": true,
50-
"npm.runSilent": true,
51-
"explorer.confirmDragAndDrop": true,
49+
"breadcrumbs.enabled": true,
50+
"npm.runSilent": true,
51+
"explorer.confirmDragAndDrop": true,
5252

53-
"[javascript]": {
54-
"editor.defaultFormatter": "esbenp.prettier-vscode",
55-
"editor.suggestSelection": "recentlyUsedByPrefix",
56-
"editor.suggest.showKeywords": true
57-
},
53+
"[javascript]": {
54+
"editor.defaultFormatter": "esbenp.prettier-vscode",
55+
"editor.suggestSelection": "recentlyUsedByPrefix",
56+
"editor.suggest.showKeywords": true
57+
},
5858

59-
"[json]": {
60-
"breadcrumbs.showBooleans": true
61-
},
59+
"[json]": {
60+
"breadcrumbs.showBooleans": true
61+
},
6262

63-
"files.associations": {
64-
"*.react.js": "javascriptreact",
65-
"*.jsx": "javascriptreact"
66-
},
67-
"terminal.integrated.fontSize": 20,
68-
"screencastMode.fontSize": 59,
69-
"scm.inputFontSize": 20
63+
"files.associations": {
64+
"*.react.js": "javascriptreact",
65+
"*.jsx": "javascriptreact"
66+
},
67+
"terminal.integrated.fontSize": 20,
68+
"screencastMode.fontSize": 59,
69+
"scm.inputFontSize": 20
7070
}

.yarn/install-state.gz

876 KB
Binary file not shown.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

package.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"license": "UNLICENSED",
88
"scripts": {
99
"build": "nest build",
10-
"lint": "yarn run eslint ./src/** --ext ts,tsx --fix",
10+
"lint": "yarn run eslint ./src/**/*.{ts,tsx} --fix",
1111
"format": "prettier --write ./src",
1212
"ts-validate": "tsc",
1313
"validate": "yarn run ts-validate && yarn run format && yarn run lint",
@@ -20,14 +20,20 @@
2020
"test:cov": "jest --coverage",
2121
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
2222
"test:e2e": "jest --config ./test/jest-e2e.json",
23-
"prepare": "husky install"
23+
"prepare": "husky install",
24+
"gql-to-interfaces": "cd ./src && ts-node schema-to-typings"
2425
},
2526
"dependencies": {
27+
"@apollo/server": "^4.10.4",
28+
"@nestjs/apollo": "^12.1.0",
2629
"@nestjs/common": "^10.0.0",
2730
"@nestjs/core": "^10.0.0",
31+
"@nestjs/graphql": "^12.1.1",
2832
"@nestjs/platform-express": "^10.0.0",
33+
"graphql": "^16.8.1",
2934
"reflect-metadata": "^0.1.13",
30-
"rxjs": "^7.8.1"
35+
"rxjs": "^7.8.1",
36+
"ts-morph": "^22.0.0"
3137
},
3238
"devDependencies": {
3339
"@nestjs/cli": "^10.0.0",
@@ -47,6 +53,7 @@
4753
"eslint-plugin-jest": "^27.6.0",
4854
"eslint-plugin-prettier": "^5.1.2",
4955
"eslint-plugin-sonarjs": "^0.23.0",
56+
"husky": "^8.0.0",
5057
"jest": "^29.5.0",
5158
"prettier": "^3.0.0",
5259
"source-map-support": "^0.5.21",
@@ -55,8 +62,7 @@
5562
"ts-loader": "^9.4.3",
5663
"ts-node": "^10.9.1",
5764
"tsconfig-paths": "^4.2.0",
58-
"typescript": "^5.1.3",
59-
"husky": "^8.0.0"
65+
"typescript": "^5.1.3"
6066
},
6167
"jest": {
6268
"moduleFileExtensions": [
@@ -74,5 +80,6 @@
7480
],
7581
"coverageDirectory": "../coverage",
7682
"testEnvironment": "node"
77-
}
83+
},
84+
"packageManager": "yarn@4.2.2"
7885
}

0 commit comments

Comments
 (0)