@smartive/graphql-magic 16.4.0-next.1 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +2 -4
- package/.github/workflows/testing.yml +0 -4
- package/.gqmrc.json +2 -2
- package/CHANGELOG.md +1 -6
- package/README.md +1 -1
- package/dist/bin/gqm.cjs +20 -24
- package/dist/cjs/index.cjs +21 -26
- package/dist/esm/migrations/generate.d.ts +1 -1
- package/dist/esm/migrations/generate.js +15 -19
- package/dist/esm/migrations/generate.js.map +1 -1
- package/dist/esm/resolvers/mutations.js +4 -5
- package/dist/esm/resolvers/mutations.js.map +1 -1
- package/dist/esm/resolvers/utils.js +2 -2
- package/dist/esm/resolvers/utils.js.map +1 -1
- package/docs/package-lock.json +138 -3207
- package/docs/package.json +1 -7
- package/docs/src/components/HomepageFeatures/index.tsx +15 -3
- package/docs/src/pages/index.tsx +0 -2
- package/docs/tsconfig.json +1 -2
- package/eslint.config.mjs +5 -1
- package/package.json +6 -6
- package/src/bin/gqm/gqm.ts +2 -2
- package/src/bin/gqm/parse-knexfile.ts +0 -1
- package/src/bin/gqm/settings.ts +2 -6
- package/src/bin/gqm/static-eval.ts +0 -8
- package/src/bin/gqm/utils.ts +0 -1
- package/src/bin/gqm/visitor.ts +2 -2
- package/src/migrations/generate.ts +16 -23
- package/src/resolvers/mutations.ts +4 -5
- package/src/resolvers/utils.ts +2 -2
- package/tsconfig.eslint.json +20 -0
- package/tsconfig.jest.json +4 -13
- package/tsconfig.json +12 -2
- package/docs/.prettierignore +0 -34
- package/docs/.prettierrc.json +0 -1
- package/docs/docs/11-migration-guides.md +0 -19
- package/docs/eslint.config.mjs +0 -31
- package/tsconfig.library.json +0 -18
package/docs/package.json
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docusaurus": "docusaurus",
|
|
7
7
|
"start": "docusaurus start",
|
|
8
|
-
"lint": "eslint",
|
|
9
|
-
"lint:fix": "eslint --fix",
|
|
10
8
|
"build": "docusaurus build",
|
|
11
9
|
"swizzle": "docusaurus swizzle",
|
|
12
10
|
"deploy": "docusaurus deploy",
|
|
@@ -29,11 +27,7 @@
|
|
|
29
27
|
"@docusaurus/module-type-aliases": "3.7.0",
|
|
30
28
|
"@docusaurus/tsconfig": "3.7.0",
|
|
31
29
|
"@docusaurus/types": "3.7.0",
|
|
32
|
-
"
|
|
33
|
-
"@smartive/prettier-config": "^3.1.2",
|
|
34
|
-
"eslint": "^9.21.0",
|
|
35
|
-
"eslint-plugin-react": "^7.37.4",
|
|
36
|
-
"typescript": "5.7.3"
|
|
30
|
+
"typescript": "5.8.2"
|
|
37
31
|
},
|
|
38
32
|
"browserslist": {
|
|
39
33
|
"production": [
|
|
@@ -12,17 +12,29 @@ const FeatureList: FeatureItem[] = [
|
|
|
12
12
|
{
|
|
13
13
|
title: 'Model-first',
|
|
14
14
|
Svg: require('@site/static/img/undraw_docusaurus_mountain.svg').default,
|
|
15
|
-
description:
|
|
15
|
+
description: (
|
|
16
|
+
<>
|
|
17
|
+
Define your model, generate everything else.
|
|
18
|
+
</>
|
|
19
|
+
),
|
|
16
20
|
},
|
|
17
21
|
{
|
|
18
22
|
title: 'CLI',
|
|
19
23
|
Svg: require('@site/static/img/undraw_docusaurus_tree.svg').default,
|
|
20
|
-
description:
|
|
24
|
+
description: (
|
|
25
|
+
<>
|
|
26
|
+
Generate things with our cli.
|
|
27
|
+
</>
|
|
28
|
+
),
|
|
21
29
|
},
|
|
22
30
|
{
|
|
23
31
|
title: 'Brought to you by smartive',
|
|
24
32
|
Svg: require('@site/static/img/undraw_docusaurus_react.svg').default,
|
|
25
|
-
description:
|
|
33
|
+
description: (
|
|
34
|
+
<>
|
|
35
|
+
We developed this as an internal tool.
|
|
36
|
+
</>
|
|
37
|
+
),
|
|
26
38
|
},
|
|
27
39
|
];
|
|
28
40
|
|
package/docs/src/pages/index.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import styles from './index.module.css';
|
|
|
9
9
|
|
|
10
10
|
function HomepageHeader() {
|
|
11
11
|
const { siteConfig } = useDocusaurusContext();
|
|
12
|
-
|
|
13
12
|
return (
|
|
14
13
|
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
|
15
14
|
<div className="container">
|
|
@@ -29,7 +28,6 @@ function HomepageHeader() {
|
|
|
29
28
|
|
|
30
29
|
export default function Home(): JSX.Element {
|
|
31
30
|
const { siteConfig } = useDocusaurusContext();
|
|
32
|
-
|
|
33
31
|
return (
|
|
34
32
|
<Layout title={`Hello from ${siteConfig.title}`} description="Description will go into a meta tag in <head />">
|
|
35
33
|
<HomepageHeader />
|
package/docs/tsconfig.json
CHANGED
package/eslint.config.mjs
CHANGED
|
@@ -4,10 +4,15 @@ import tsParser from "@typescript-eslint/parser";
|
|
|
4
4
|
export default [
|
|
5
5
|
...config('typescript'),
|
|
6
6
|
{
|
|
7
|
+
files: ['src/**/*.ts'],
|
|
7
8
|
languageOptions: {
|
|
8
9
|
parser: tsParser,
|
|
9
10
|
ecmaVersion: 5,
|
|
10
11
|
sourceType: "script",
|
|
12
|
+
|
|
13
|
+
parserOptions: {
|
|
14
|
+
project: "./tsconfig.eslint.json",
|
|
15
|
+
},
|
|
11
16
|
},
|
|
12
17
|
|
|
13
18
|
rules: {
|
|
@@ -32,7 +37,6 @@ export default [
|
|
|
32
37
|
"@typescript-eslint/require-await": "off",
|
|
33
38
|
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
34
39
|
"eqeqeq": "off",
|
|
35
|
-
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
36
40
|
},
|
|
37
41
|
},
|
|
38
42
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartive/graphql-magic",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"generate:index-files": "cti create ./src --excludes bin --withoutbackup",
|
|
18
18
|
"generate:gqm-stuff": "npx gqm generate",
|
|
19
19
|
"generate:setup-migration": "npm run build:bin && npx gqm generate-migration setup 20230912185644",
|
|
20
|
-
"lint": "eslint src",
|
|
20
|
+
"lint": "eslint src/**/*.ts",
|
|
21
21
|
"lint:fix": "eslint src --fix",
|
|
22
22
|
"deps": "docker compose up",
|
|
23
23
|
"test": "npm run lint && npm run test:all && npm run build",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"clean": "del-cli dist/**",
|
|
28
28
|
"prebuild": "npm run clean",
|
|
29
29
|
"build": "npm run build:esm && npm run build:cjs && npm run build:bin",
|
|
30
|
-
"build:esm": "tsc
|
|
30
|
+
"build:esm": "tsc",
|
|
31
31
|
"build:cjs": "esbuild src/index.ts --bundle --platform=node --outdir=dist/cjs --out-extension:.js=.cjs --format=cjs --packages=external",
|
|
32
32
|
"build:bin": "esbuild src/bin/gqm/gqm.ts --bundle --platform=node --outdir=dist/bin --out-extension:.js=.cjs --format=cjs --packages=external"
|
|
33
33
|
},
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@smartive/eslint-config": "6.5.0",
|
|
69
69
|
"@smartive/prettier-config": "3.1.2",
|
|
70
70
|
"@types/jest": "29.5.14",
|
|
71
|
-
"@types/lodash": "4.17.
|
|
71
|
+
"@types/lodash": "4.17.16",
|
|
72
72
|
"@types/luxon": "3.4.2",
|
|
73
73
|
"@types/pg": "8.11.11",
|
|
74
74
|
"@types/uuid": "10.0.0",
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
"eslint": "9.21.0",
|
|
79
79
|
"jest": "29.7.0",
|
|
80
80
|
"mock-knex": "0.4.13",
|
|
81
|
-
"prettier": "3.5.
|
|
81
|
+
"prettier": "3.5.3",
|
|
82
82
|
"ts-jest": "29.2.6",
|
|
83
83
|
"ts-node": "10.9.2",
|
|
84
|
-
"typescript": "5.
|
|
84
|
+
"typescript": "5.8.2"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/bin/gqm/gqm.ts
CHANGED
|
@@ -35,9 +35,9 @@ program
|
|
|
35
35
|
await getSetting('knexfilePath');
|
|
36
36
|
const models = await parseModels();
|
|
37
37
|
const generatedFolderPath = await getSetting('generatedFolderPath');
|
|
38
|
-
const
|
|
38
|
+
const gqlModule = await getSetting('gqlModule');
|
|
39
39
|
writeToFile(`${generatedFolderPath}/schema.graphql`, printSchemaFromModels(models));
|
|
40
|
-
writeToFile(`${generatedFolderPath}/client/mutations.ts`, generateMutations(models,
|
|
40
|
+
writeToFile(`${generatedFolderPath}/client/mutations.ts`, generateMutations(models, gqlModule));
|
|
41
41
|
const dateLibrary = (await getSetting('dateLibrary')) as DateLibrary;
|
|
42
42
|
writeToFile(`${generatedFolderPath}/db/index.ts`, generateDBModels(models, dateLibrary));
|
|
43
43
|
writeToFile(`${generatedFolderPath}/db/knex.ts`, generateKnexTables(models));
|
|
@@ -16,6 +16,5 @@ export const parseKnexfile = async () => {
|
|
|
16
16
|
const sourceFile = project.addSourceFileAtPath(knexfilePath);
|
|
17
17
|
const configDeclaration = findDeclarationInFile(sourceFile, 'knexConfig');
|
|
18
18
|
const config = staticEval(configDeclaration, {});
|
|
19
|
-
|
|
20
19
|
return config;
|
|
21
20
|
};
|
package/src/bin/gqm/settings.ts
CHANGED
|
@@ -58,7 +58,7 @@ const DEFAULTS = {
|
|
|
58
58
|
ensureFileExists(`${path}/execute.ts`, EXECUTE);
|
|
59
59
|
},
|
|
60
60
|
},
|
|
61
|
-
|
|
61
|
+
gqlModule: {
|
|
62
62
|
defaultValue: '@smartive/graphql-magic',
|
|
63
63
|
},
|
|
64
64
|
dateLibrary: {
|
|
@@ -97,7 +97,6 @@ const initSetting = async (name: string) => {
|
|
|
97
97
|
const { question, defaultValue, init } = DEFAULTS[name];
|
|
98
98
|
const value = (await readLine(`${question} (${defaultValue})`)) || defaultValue;
|
|
99
99
|
await init(value);
|
|
100
|
-
|
|
101
100
|
return value;
|
|
102
101
|
};
|
|
103
102
|
|
|
@@ -112,14 +111,13 @@ const initSettings = async () => {
|
|
|
112
111
|
};
|
|
113
112
|
|
|
114
113
|
const saveSettings = (settings: Settings) => {
|
|
115
|
-
writeToFile(SETTINGS_PATH, JSON.stringify(settings, null, 2)
|
|
114
|
+
writeToFile(SETTINGS_PATH, JSON.stringify(settings, null, 2));
|
|
116
115
|
};
|
|
117
116
|
|
|
118
117
|
export const getSettings = async (): Promise<Settings> => {
|
|
119
118
|
if (!existsSync(SETTINGS_PATH)) {
|
|
120
119
|
await initSettings();
|
|
121
120
|
}
|
|
122
|
-
|
|
123
121
|
return JSON.parse(readFileSync(SETTINGS_PATH, 'utf8'));
|
|
124
122
|
};
|
|
125
123
|
|
|
@@ -133,7 +131,6 @@ export const getSetting = async (name: keyof Settings): Promise<string> => {
|
|
|
133
131
|
return DEFAULTS[name].defaultValue;
|
|
134
132
|
}
|
|
135
133
|
}
|
|
136
|
-
|
|
137
134
|
return settings[name];
|
|
138
135
|
};
|
|
139
136
|
|
|
@@ -147,7 +144,6 @@ export const ensureDirectoryExists = (dir: string) => {
|
|
|
147
144
|
try {
|
|
148
145
|
console.info(`Creating directory ${dir}`);
|
|
149
146
|
mkdirSync(dir);
|
|
150
|
-
|
|
151
147
|
return true;
|
|
152
148
|
} catch (err) {
|
|
153
149
|
if (err.code === 'EEXIST') {
|
|
@@ -29,7 +29,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
29
29
|
values.push(staticEval(value, context));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
return values;
|
|
34
33
|
},
|
|
35
34
|
[SyntaxKind.ObjectLiteralExpression]: (node: ObjectLiteralExpression, context) => {
|
|
@@ -37,7 +36,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
37
36
|
for (const property of node.getProperties()) {
|
|
38
37
|
Object.assign(result, staticEval(property, context));
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
return result;
|
|
42
40
|
},
|
|
43
41
|
[SyntaxKind.StringLiteral]: (node) => node.getLiteralValue(),
|
|
@@ -64,7 +62,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
64
62
|
if (!definitionNodes.length) {
|
|
65
63
|
throw new Error(`No definition node found for identifier ${node.getText()}.`);
|
|
66
64
|
}
|
|
67
|
-
|
|
68
65
|
return staticEval(definitionNodes[0], context);
|
|
69
66
|
},
|
|
70
67
|
[SyntaxKind.ParenthesizedExpression]: (node, context) => staticEval(node.getExpression(), context),
|
|
@@ -80,7 +77,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
80
77
|
[SyntaxKind.CallExpression]: (node, context) => {
|
|
81
78
|
const method = staticEval(node.getExpression(), context) as (...args: unknown[]) => unknown;
|
|
82
79
|
const args = node.getArguments().map((arg) => staticEval(arg, context));
|
|
83
|
-
|
|
84
80
|
return method(...args);
|
|
85
81
|
},
|
|
86
82
|
[SyntaxKind.PropertyAccessExpression]: (node, context) => {
|
|
@@ -119,7 +115,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
119
115
|
parameters[parameter.getName()] = args[i];
|
|
120
116
|
i++;
|
|
121
117
|
}
|
|
122
|
-
|
|
123
118
|
return staticEval(node.getBody(), { ...context, ...parameters });
|
|
124
119
|
};
|
|
125
120
|
},
|
|
@@ -134,7 +129,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
134
129
|
console.error(node.getText());
|
|
135
130
|
throw new Error(`Can only handle code blocks with 1 statement.`);
|
|
136
131
|
}
|
|
137
|
-
|
|
138
132
|
return staticEval(statements[0], context);
|
|
139
133
|
},
|
|
140
134
|
[SyntaxKind.DefaultClause]: (node, context) => {
|
|
@@ -143,7 +137,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
143
137
|
console.error(node.getText());
|
|
144
138
|
throw new Error(`Can only handle code blocks with exactly 1 statement.`);
|
|
145
139
|
}
|
|
146
|
-
|
|
147
140
|
return staticEval(statements[0], context);
|
|
148
141
|
},
|
|
149
142
|
[SyntaxKind.ReturnStatement]: (node, context) => {
|
|
@@ -212,7 +205,6 @@ const VISITOR: Visitor<unknown, Dictionary<unknown>> = {
|
|
|
212
205
|
[SyntaxKind.ElementAccessExpression]: (node: ElementAccessExpression, context) => {
|
|
213
206
|
const target = staticEval(node.getExpression(), context);
|
|
214
207
|
const argument = staticEval(node.getArgumentExpression(), context) as string;
|
|
215
|
-
|
|
216
208
|
return target[argument];
|
|
217
209
|
},
|
|
218
210
|
[SyntaxKind.NoSubstitutionTemplateLiteral]: (node) => node.getLiteralValue(),
|
package/src/bin/gqm/utils.ts
CHANGED
package/src/bin/gqm/visitor.ts
CHANGED
|
@@ -23,7 +23,7 @@ type Callbacks = (() => void)[];
|
|
|
23
23
|
|
|
24
24
|
export class MigrationGenerator {
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
26
|
-
private writer = new CodeBlockWriter['default']({
|
|
26
|
+
private writer: CodeBlockWriter = new CodeBlockWriter['default']({
|
|
27
27
|
useSingleQuote: true,
|
|
28
28
|
indentNumberOfSpaces: 2,
|
|
29
29
|
});
|
|
@@ -82,35 +82,34 @@ export class MigrationGenerator {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
if (oldName) {
|
|
85
|
+
if (model.oldName) {
|
|
87
86
|
// Rename table
|
|
88
87
|
up.push(() => {
|
|
89
|
-
this.renameTable(oldName
|
|
88
|
+
this.renameTable(model.oldName!, model.name);
|
|
90
89
|
});
|
|
91
90
|
down.push(() => {
|
|
92
|
-
this.renameTable(model.name, oldName);
|
|
91
|
+
this.renameTable(model.name, model.oldName!);
|
|
93
92
|
});
|
|
94
|
-
tables[tables.indexOf(oldName)] = model.name;
|
|
95
|
-
this.columns[model.name] = this.columns[oldName];
|
|
96
|
-
delete this.columns[oldName];
|
|
93
|
+
tables[tables.indexOf(model.oldName)] = model.name;
|
|
94
|
+
this.columns[model.name] = this.columns[model.oldName];
|
|
95
|
+
delete this.columns[model.oldName];
|
|
97
96
|
|
|
98
97
|
if (isUpdatableModel(model)) {
|
|
99
98
|
up.push(() => {
|
|
100
|
-
this.renameTable(`${oldName}Revision`, `${model.name}Revision`);
|
|
99
|
+
this.renameTable(`${model.oldName}Revision`, `${model.name}Revision`);
|
|
101
100
|
this.alterTable(`${model.name}Revision`, () => {
|
|
102
101
|
this.renameColumn(`${typeToField(get(model, 'oldName'))}Id`, `${typeToField(model.name)}Id`);
|
|
103
102
|
});
|
|
104
103
|
});
|
|
105
104
|
down.push(() => {
|
|
106
|
-
this.renameTable(`${model.name}Revision`, `${oldName}Revision`);
|
|
107
|
-
this.alterTable(`${oldName}Revision`, () => {
|
|
105
|
+
this.renameTable(`${model.name}Revision`, `${model.oldName}Revision`);
|
|
106
|
+
this.alterTable(`${model.oldName}Revision`, () => {
|
|
108
107
|
this.renameColumn(`${typeToField(model.name)}Id`, `${typeToField(get(model, 'oldName'))}Id`);
|
|
109
108
|
});
|
|
110
109
|
});
|
|
111
|
-
tables[tables.indexOf(`${oldName}Revision`)] = `${model.name}Revision`;
|
|
112
|
-
this.columns[`${model.name}Revision`] = this.columns[`${oldName}Revision`];
|
|
113
|
-
delete this.columns[`${oldName}Revision`];
|
|
110
|
+
tables[tables.indexOf(`${model.oldName}Revision`)] = `${model.name}Revision`;
|
|
111
|
+
this.columns[`${model.name}Revision`] = this.columns[`${model.oldName}Revision`];
|
|
112
|
+
delete this.columns[`${model.oldName}Revision`];
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
|
|
@@ -311,11 +310,9 @@ export class MigrationGenerator {
|
|
|
311
310
|
|
|
312
311
|
up.push(() => {
|
|
313
312
|
for (const field of fields) {
|
|
314
|
-
const oldName = get(field, 'oldName');
|
|
315
|
-
|
|
316
313
|
this.alterTable(model.name, () => {
|
|
317
314
|
this.renameColumn(
|
|
318
|
-
field.kind === 'relation' ? `${oldName}Id` : oldName,
|
|
315
|
+
field.kind === 'relation' ? `${field.oldName}Id` : get(field, 'oldName'),
|
|
319
316
|
field.kind === 'relation' ? `${field.name}Id` : field.name,
|
|
320
317
|
);
|
|
321
318
|
});
|
|
@@ -324,21 +321,17 @@ export class MigrationGenerator {
|
|
|
324
321
|
|
|
325
322
|
down.push(() => {
|
|
326
323
|
for (const field of fields) {
|
|
327
|
-
const oldName = get(field, 'oldName');
|
|
328
|
-
|
|
329
324
|
this.alterTable(model.name, () => {
|
|
330
325
|
this.renameColumn(
|
|
331
326
|
field.kind === 'relation' ? `${field.name}Id` : field.name,
|
|
332
|
-
field.kind === 'relation' ? `${oldName}Id` : oldName,
|
|
327
|
+
field.kind === 'relation' ? `${field.oldName}Id` : get(field, 'oldName'),
|
|
333
328
|
);
|
|
334
329
|
});
|
|
335
330
|
}
|
|
336
331
|
});
|
|
337
332
|
|
|
338
333
|
for (const field of fields) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
summonByName(this.columns[model.name], field.kind === 'relation' ? `${oldName}Id` : oldName).name =
|
|
334
|
+
summonByName(this.columns[model.name], field.kind === 'relation' ? `${field.oldName!}Id` : field.oldName!).name =
|
|
342
335
|
field.kind === 'relation' ? `${field.name}Id` : field.name;
|
|
343
336
|
}
|
|
344
337
|
}
|
|
@@ -280,19 +280,18 @@ const restore = async (model: EntityModel, { where }: { where: any }, ctx: FullC
|
|
|
280
280
|
|
|
281
281
|
const normalizedInput: Entity = { deleted: false, deletedAt: null, deletedById: null };
|
|
282
282
|
const data = { prev: relatedEntity, input: {}, normalizedInput, next: { ...relatedEntity, ...normalizedInput } };
|
|
283
|
-
|
|
284
|
-
if (mutationHook) {
|
|
283
|
+
if (ctx.mutationHook) {
|
|
285
284
|
beforeHooks.push(async () => {
|
|
286
|
-
await mutationHook(currentModel, 'restore', 'before', data, ctx);
|
|
285
|
+
await ctx.mutationHook!(currentModel, 'restore', 'before', data, ctx);
|
|
287
286
|
});
|
|
288
287
|
}
|
|
289
288
|
mutations.push(async () => {
|
|
290
289
|
await ctx.knex(currentModel.name).where({ id: relatedEntity.id }).update(normalizedInput);
|
|
291
290
|
await createRevision(currentModel, { ...relatedEntity, deleted: false }, ctx);
|
|
292
291
|
});
|
|
293
|
-
if (mutationHook) {
|
|
292
|
+
if (ctx.mutationHook) {
|
|
294
293
|
afterHooks.push(async () => {
|
|
295
|
-
await mutationHook(currentModel, 'restore', 'after', data, ctx);
|
|
294
|
+
await ctx.mutationHook!(currentModel, 'restore', 'after', data, ctx);
|
|
296
295
|
});
|
|
297
296
|
}
|
|
298
297
|
|
package/src/resolvers/utils.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { Knex } from 'knex';
|
|
|
14
14
|
import { isEqual } from 'lodash';
|
|
15
15
|
import { EntityField } from '..';
|
|
16
16
|
import { UserInputError } from '../errors';
|
|
17
|
-
import { get, it
|
|
17
|
+
import { get, it } from '../models/utils';
|
|
18
18
|
import { Value } from '../values';
|
|
19
19
|
import { FieldResolverNode, ResolverNode } from './node';
|
|
20
20
|
|
|
@@ -205,7 +205,7 @@ export const getColumnName = (field: EntityField) =>
|
|
|
205
205
|
field.kind === 'relation' ? field.foreignKey || `${field.name}Id` : field.name;
|
|
206
206
|
|
|
207
207
|
export const getColumn = (node: Pick<ResolverNode, 'model' | 'ctx' | 'rootTableAlias' | 'tableAlias'>, key: string) => {
|
|
208
|
-
const field =
|
|
208
|
+
const field = node.model.fields.find((field) => getColumnName(field) === key)!;
|
|
209
209
|
|
|
210
210
|
return `${node.ctx.aliases.getShort(field.inherited ? node.rootTableAlias : node.tableAlias)}.${key}`;
|
|
211
211
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**/*",
|
|
4
|
+
],
|
|
5
|
+
"exclude": [
|
|
6
|
+
"node_modules",
|
|
7
|
+
"dist",
|
|
8
|
+
"build"
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"outDir": "./dist/esm",
|
|
12
|
+
"rootDir": "./src",
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"target": "esnext",
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
"strictNullChecks": true,
|
|
18
|
+
"allowSyntheticDefaultImports": true
|
|
19
|
+
},
|
|
20
|
+
}
|
package/tsconfig.jest.json
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "./tsconfig.
|
|
3
|
-
"include": [
|
|
4
|
-
|
|
5
|
-
"**/*.tsx",
|
|
6
|
-
"**/unit/**/*.spec.ts"
|
|
7
|
-
],
|
|
8
|
-
"exclude": [
|
|
9
|
-
"node_modules",
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"include": ["**/*.ts", "**/*.tsx", "**/unit/**/*.spec.ts"],
|
|
4
|
+
"exclude": ["node_modules", "dist"],
|
|
12
5
|
"compilerOptions": {
|
|
13
6
|
"rootDir": "./",
|
|
14
|
-
"types": [
|
|
15
|
-
"jest"
|
|
16
|
-
],
|
|
7
|
+
"types": ["jest"],
|
|
17
8
|
"esModuleInterop": true,
|
|
18
9
|
"moduleResolution": "node",
|
|
19
10
|
"isolatedModules": true,
|
package/tsconfig.json
CHANGED
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
"include": [
|
|
3
3
|
"./src/**/*.ts",
|
|
4
4
|
"./src/**/*.tsx",
|
|
5
|
-
"./tests/**/*.ts",
|
|
6
|
-
"./tests/**/*.tsx"
|
|
7
5
|
],
|
|
8
6
|
"exclude": [
|
|
9
7
|
"node_modules",
|
|
10
8
|
"dist",
|
|
9
|
+
"src/bin"
|
|
11
10
|
],
|
|
11
|
+
"compilerOptions": {
|
|
12
|
+
"outDir": "./dist/esm",
|
|
13
|
+
"rootDir": "./src",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"target": "esnext",
|
|
17
|
+
"moduleResolution": "bundler",
|
|
18
|
+
"skipLibCheck": true,
|
|
19
|
+
"strictNullChecks": true,
|
|
20
|
+
"allowSyntheticDefaultImports": true
|
|
21
|
+
},
|
|
12
22
|
}
|
package/docs/.prettierignore
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# dependencies
|
|
4
|
-
/node_modules
|
|
5
|
-
/.pnp
|
|
6
|
-
.pnp.js
|
|
7
|
-
|
|
8
|
-
# testing
|
|
9
|
-
/coverage
|
|
10
|
-
|
|
11
|
-
# next.js
|
|
12
|
-
/.next/
|
|
13
|
-
/out/
|
|
14
|
-
|
|
15
|
-
# production
|
|
16
|
-
/build
|
|
17
|
-
|
|
18
|
-
# misc
|
|
19
|
-
.DS_Store
|
|
20
|
-
*.pem
|
|
21
|
-
|
|
22
|
-
# debug
|
|
23
|
-
npm-debug.log*
|
|
24
|
-
yarn-debug.log*
|
|
25
|
-
yarn-error.log*
|
|
26
|
-
|
|
27
|
-
# local env files
|
|
28
|
-
.env.local
|
|
29
|
-
.env.development.local
|
|
30
|
-
.env.test.local
|
|
31
|
-
.env.production.local
|
|
32
|
-
|
|
33
|
-
# vercel
|
|
34
|
-
.vercel
|
package/docs/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"@smartive/prettier-config"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Migration Guides
|
|
2
|
-
|
|
3
|
-
## Upgrading to v17.0.0
|
|
4
|
-
|
|
5
|
-
### Configuration changes
|
|
6
|
-
|
|
7
|
-
- The `gqlModule` configuration property has been renamed to `gqmModule` to maintain consistency with the project naming. Please update your `.gqmrc.json` file accordingly:
|
|
8
|
-
|
|
9
|
-
```diff
|
|
10
|
-
{
|
|
11
|
-
"modelsPath": "path/to/models.ts",
|
|
12
|
-
"generatedFolderPath": "path/to/generated",
|
|
13
|
-
"graphqlQueriesPath": "path/to/queries",
|
|
14
|
-
- "gqlModule": "../path/to/module",
|
|
15
|
-
+ "gqmModule": "../path/to/module",
|
|
16
|
-
"knexfilePath": "knexfile.ts",
|
|
17
|
-
"dateLibrary": "luxon"
|
|
18
|
-
}
|
|
19
|
-
```
|
package/docs/eslint.config.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { config } from '@smartive/eslint-config';
|
|
2
|
-
|
|
3
|
-
/** @type {import('eslint').Linter.Config[]} */
|
|
4
|
-
export default [
|
|
5
|
-
...config('typescript'),
|
|
6
|
-
{
|
|
7
|
-
files: ['**/*.{ts,tsx,js,jsx,mjs}'],
|
|
8
|
-
settings: {
|
|
9
|
-
'import/resolver': {
|
|
10
|
-
node: {
|
|
11
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
12
|
-
},
|
|
13
|
-
typescript: {
|
|
14
|
-
alwaysTryTypes: true,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
'import/no-unresolved': [
|
|
20
|
-
'error',
|
|
21
|
-
{
|
|
22
|
-
ignore: ['^@theme', '^@docusaurus', '^@site'],
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
'@typescript-eslint/no-require-imports': 'off',
|
|
26
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
27
|
-
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
28
|
-
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
];
|
package/tsconfig.library.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"exclude": [
|
|
4
|
-
"tests",
|
|
5
|
-
"src/bin"
|
|
6
|
-
],
|
|
7
|
-
"compilerOptions": {
|
|
8
|
-
"outDir": "./dist/esm",
|
|
9
|
-
"rootDir": "./src",
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"declaration": true,
|
|
12
|
-
"target": "esnext",
|
|
13
|
-
"moduleResolution": "bundler",
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"strictNullChecks": true,
|
|
16
|
-
"allowSyntheticDefaultImports": true
|
|
17
|
-
},
|
|
18
|
-
}
|