@constructive-io/graphql-codegen 4.29.0 → 4.29.2
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/core/codegen/cli/index.d.ts +0 -2
- package/core/codegen/cli/index.js +0 -4
- package/core/codegen/cli/table-command-generator.d.ts +0 -2
- package/core/codegen/cli/table-command-generator.js +14 -25
- package/core/codegen/index.js +0 -3
- package/core/codegen/orm/index.js +2 -3
- package/core/codegen/orm/input-types-generator.d.ts +1 -3
- package/core/codegen/orm/input-types-generator.js +3 -113
- package/core/codegen/orm/model-generator.d.ts +2 -6
- package/core/codegen/orm/model-generator.js +2 -27
- package/core/codegen/orm/select-types.d.ts +2 -4
- package/core/codegen/queries.d.ts +0 -1
- package/core/codegen/queries.js +1 -7
- package/core/codegen/templates/cli-utils.ts +1 -5
- package/core/codegen/templates/query-builder.ts +3 -26
- package/core/codegen/templates/select-types.ts +2 -4
- package/core/generate.js +0 -2
- package/esm/core/codegen/cli/index.d.ts +0 -2
- package/esm/core/codegen/cli/index.js +0 -4
- package/esm/core/codegen/cli/table-command-generator.d.ts +0 -2
- package/esm/core/codegen/cli/table-command-generator.js +15 -26
- package/esm/core/codegen/index.js +0 -3
- package/esm/core/codegen/orm/index.js +2 -3
- package/esm/core/codegen/orm/input-types-generator.d.ts +1 -3
- package/esm/core/codegen/orm/input-types-generator.js +4 -114
- package/esm/core/codegen/orm/model-generator.d.ts +2 -6
- package/esm/core/codegen/orm/model-generator.js +2 -27
- package/esm/core/codegen/orm/select-types.d.ts +2 -4
- package/esm/core/codegen/queries.d.ts +0 -1
- package/esm/core/codegen/queries.js +2 -8
- package/esm/core/generate.js +0 -2
- package/package.json +7 -7
|
@@ -7,7 +7,6 @@ export interface QueryGeneratorOptions {
|
|
|
7
7
|
reactQueryEnabled?: boolean;
|
|
8
8
|
useCentralizedKeys?: boolean;
|
|
9
9
|
hasRelationships?: boolean;
|
|
10
|
-
condition?: boolean;
|
|
11
10
|
}
|
|
12
11
|
export declare function generateListQueryHook(table: Table, options?: QueryGeneratorOptions): GeneratedQueryFile;
|
|
13
12
|
export declare function generateSingleQueryHook(table: Table, options?: QueryGeneratorOptions): GeneratedQueryFile | null;
|
|
@@ -9,15 +9,14 @@
|
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { asConst } from './babel-ast';
|
|
11
11
|
import { addJSDocComment, buildFindManyCallExpr, buildFindOneCallExpr, buildListSelectionArgsCall, buildSelectionArgsCall, callExpr, createFunctionParam, createImportDeclaration, createSAndTDataTypeParams, createSTypeParam, createTypeReExport, destructureParamsWithSelection, destructureParamsWithSelectionAndScope, exportAsyncDeclareFunction, exportAsyncFunction, exportDeclareFunction, exportFunction, generateHookFileCode, listQueryResultType, listSelectionConfigType, objectProp, omitType, returnUseQuery, scopeTypeLiteral, selectionConfigType, singleQueryResultType, spreadObj, sRef, typeRef, useQueryOptionsImplType, voidStatement, withFieldsListSelectionType, withFieldsSelectionType, } from './hooks-ast';
|
|
12
|
-
import { getAllRowsQueryName,
|
|
12
|
+
import { getAllRowsQueryName, getFilterTypeName, getListQueryFileName, getListQueryHookName, getOrderByTypeName, getPrimaryKeyInfo, getSingleQueryFileName, getSingleQueryHookName, getSingleRowQueryName, getTableNames, hasValidPrimaryKey, lcFirst, ucFirst, } from './utils';
|
|
13
13
|
export function generateListQueryHook(table, options = {}) {
|
|
14
|
-
const { reactQueryEnabled = true, useCentralizedKeys = true, hasRelationships = false,
|
|
14
|
+
const { reactQueryEnabled = true, useCentralizedKeys = true, hasRelationships = false, } = options;
|
|
15
15
|
const { typeName, pluralName, singularName } = getTableNames(table);
|
|
16
16
|
const hookName = getListQueryHookName(table);
|
|
17
17
|
const queryName = getAllRowsQueryName(table);
|
|
18
18
|
const filterTypeName = getFilterTypeName(table);
|
|
19
19
|
const orderByTypeName = getOrderByTypeName(table);
|
|
20
|
-
const conditionTypeName = conditionEnabled ? getConditionTypeName(table) : undefined;
|
|
21
20
|
const keysName = `${lcFirst(typeName)}Keys`;
|
|
22
21
|
const scopeTypeName = `${typeName}Scope`;
|
|
23
22
|
const selectTypeName = `${typeName}Select`;
|
|
@@ -39,8 +38,6 @@ export function generateListQueryHook(table, options = {}) {
|
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
const inputTypeImports = [selectTypeName, relationTypeName, filterTypeName, orderByTypeName];
|
|
42
|
-
if (conditionTypeName)
|
|
43
|
-
inputTypeImports.push(conditionTypeName);
|
|
44
41
|
statements.push(createImportDeclaration('../../orm/input-types', inputTypeImports, true));
|
|
45
42
|
statements.push(createImportDeclaration('../../orm/select-types', [
|
|
46
43
|
'FindManyArgs',
|
|
@@ -50,8 +47,6 @@ export function generateListQueryHook(table, options = {}) {
|
|
|
50
47
|
], true));
|
|
51
48
|
// Re-exports
|
|
52
49
|
const reExportTypes = [selectTypeName, relationTypeName, filterTypeName, orderByTypeName];
|
|
53
|
-
if (conditionTypeName)
|
|
54
|
-
reExportTypes.push(conditionTypeName);
|
|
55
50
|
statements.push(createTypeReExport(reExportTypes, '../../orm/input-types'));
|
|
56
51
|
// Query key
|
|
57
52
|
if (useCentralizedKeys) {
|
|
@@ -67,7 +62,6 @@ export function generateListQueryHook(table, options = {}) {
|
|
|
67
62
|
const findManyKeyTypeArgs = [
|
|
68
63
|
t.tsUnknownKeyword(),
|
|
69
64
|
typeRef(filterTypeName),
|
|
70
|
-
conditionTypeName ? typeRef(conditionTypeName) : t.tsNeverKeyword(),
|
|
71
65
|
typeRef(orderByTypeName),
|
|
72
66
|
];
|
|
73
67
|
const keyFn = t.arrowFunctionExpression([
|
package/esm/core/generate.js
CHANGED
|
@@ -545,14 +545,12 @@ export async function generateMulti(options) {
|
|
|
545
545
|
const firstTargetConfig = configs[names[0]];
|
|
546
546
|
const multiNodeHttpAdapter = firstTargetConfig?.nodeHttpAdapter === true ||
|
|
547
547
|
(firstTargetConfig?.nodeHttpAdapter !== false);
|
|
548
|
-
const multiConditionEnabled = firstTargetConfig?.codegen?.condition === true;
|
|
549
548
|
const { files } = generateMultiTargetCli({
|
|
550
549
|
toolName,
|
|
551
550
|
builtinNames: cliConfig.builtinNames,
|
|
552
551
|
targets: cliTargets,
|
|
553
552
|
nodeHttpAdapter: multiNodeHttpAdapter,
|
|
554
553
|
entryPoint: cliConfig.entryPoint,
|
|
555
|
-
condition: multiConditionEnabled,
|
|
556
554
|
});
|
|
557
555
|
const cliFilesToWrite = files.map((file) => ({
|
|
558
556
|
path: path.posix.join('cli', file.fileName),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "4.29.
|
|
3
|
+
"version": "4.29.2",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"@0no-co/graphql.web": "^1.1.2",
|
|
57
57
|
"@babel/generator": "^7.29.1",
|
|
58
58
|
"@babel/types": "^7.29.0",
|
|
59
|
-
"@constructive-io/graphql-query": "^3.13.
|
|
59
|
+
"@constructive-io/graphql-query": "^3.13.1",
|
|
60
60
|
"@constructive-io/graphql-types": "^3.4.4",
|
|
61
61
|
"@inquirerer/utils": "^3.3.5",
|
|
62
|
-
"@pgpmjs/core": "^6.11.
|
|
62
|
+
"@pgpmjs/core": "^6.11.1",
|
|
63
63
|
"ajv": "^8.18.0",
|
|
64
64
|
"deepmerge": "^4.3.1",
|
|
65
65
|
"find-and-require-package-json": "^0.9.1",
|
|
66
66
|
"gql-ast": "^3.4.2",
|
|
67
|
-
"graphile-schema": "^1.12.
|
|
67
|
+
"graphile-schema": "^1.12.1",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
69
|
"inflekt": "^0.7.1",
|
|
70
70
|
"inquirerer": "^4.7.0",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"oxfmt": "^0.42.0",
|
|
73
73
|
"pg-cache": "^3.4.4",
|
|
74
74
|
"pg-env": "^1.8.2",
|
|
75
|
-
"pgsql-client": "^3.8.
|
|
76
|
-
"pgsql-seed": "^2.8.
|
|
75
|
+
"pgsql-client": "^3.8.1",
|
|
76
|
+
"pgsql-seed": "^2.8.1",
|
|
77
77
|
"undici": "^7.24.6"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"tsx": "^4.21.0",
|
|
101
101
|
"typescript": "^5.9.3"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "79cd3e66871804a22c672c7ca2fa5e2105d4b368"
|
|
104
104
|
}
|