@constructive-io/graphql-codegen 2.29.0 → 2.31.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/cli/codegen/orm/client-generator.js +2 -32
- package/cli/codegen/orm/query-builder.js +8 -8
- package/cli/codegen/orm/query-builder.ts +1 -1
- package/cli/commands/index.d.ts +3 -1
- package/cli/commands/index.js +3 -1
- package/esm/cli/codegen/orm/client-generator.js +2 -32
- package/esm/cli/codegen/orm/query-builder.js +1 -1
- package/esm/cli/commands/index.d.ts +3 -1
- package/esm/cli/commands/index.js +1 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/index.d.ts +2 -0
- package/index.js +7 -1
- package/package.json +4 -2
|
@@ -55,39 +55,9 @@ function generateOrmClientFile() {
|
|
|
55
55
|
* DO NOT EDIT - changes will be overwritten
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
message: string;
|
|
60
|
-
locations?: { line: number; column: number }[];
|
|
61
|
-
path?: (string | number)[];
|
|
62
|
-
extensions?: Record<string, unknown>;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Discriminated union for query results
|
|
67
|
-
* Use .ok to check success, or use .unwrap() to get data or throw
|
|
68
|
-
*/
|
|
69
|
-
export type QueryResult<T> =
|
|
70
|
-
| { ok: true; data: T; errors: undefined }
|
|
71
|
-
| { ok: false; data: null; errors: GraphQLError[] };
|
|
58
|
+
import type { GraphQLAdapter, GraphQLError, QueryResult } from '@constructive-io/graphql-types';
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
* Pluggable adapter interface for GraphQL execution.
|
|
75
|
-
* Implement this interface to provide custom execution logic (e.g., for testing).
|
|
76
|
-
*/
|
|
77
|
-
export interface GraphQLAdapter {
|
|
78
|
-
/**
|
|
79
|
-
* Execute a GraphQL operation and return the result.
|
|
80
|
-
*/
|
|
81
|
-
execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>>;
|
|
82
|
-
/**
|
|
83
|
-
* Set headers for requests (optional - only implement if adapter supports headers).
|
|
84
|
-
*/
|
|
85
|
-
setHeaders?(headers: Record<string, string>): void;
|
|
86
|
-
/**
|
|
87
|
-
* Get the endpoint URL (optional - only implement if adapter has an endpoint).
|
|
88
|
-
*/
|
|
89
|
-
getEndpoint?(): string;
|
|
90
|
-
}
|
|
60
|
+
export type { GraphQLAdapter, GraphQLError, QueryResult } from '@constructive-io/graphql-types';
|
|
91
61
|
|
|
92
62
|
/**
|
|
93
63
|
* Default adapter that uses fetch for HTTP requests.
|
|
@@ -51,7 +51,7 @@ exports.buildUpdateDocument = buildUpdateDocument;
|
|
|
51
51
|
exports.buildDeleteDocument = buildDeleteDocument;
|
|
52
52
|
exports.buildCustomDocument = buildCustomDocument;
|
|
53
53
|
const t = __importStar(require("gql-ast"));
|
|
54
|
-
const
|
|
54
|
+
const graphql_web_1 = require("@0no-co/graphql.web");
|
|
55
55
|
const client_1 = require("./client");
|
|
56
56
|
class QueryBuilder {
|
|
57
57
|
config;
|
|
@@ -196,7 +196,7 @@ function buildFindManyDocument(operationName, queryField, select, args, filterTy
|
|
|
196
196
|
}),
|
|
197
197
|
],
|
|
198
198
|
});
|
|
199
|
-
return { document: (0,
|
|
199
|
+
return { document: (0, graphql_web_1.print)(document), variables };
|
|
200
200
|
}
|
|
201
201
|
function buildFindFirstDocument(operationName, queryField, select, args, filterTypeName) {
|
|
202
202
|
const selections = select
|
|
@@ -233,7 +233,7 @@ function buildFindFirstDocument(operationName, queryField, select, args, filterT
|
|
|
233
233
|
}),
|
|
234
234
|
],
|
|
235
235
|
});
|
|
236
|
-
return { document: (0,
|
|
236
|
+
return { document: (0, graphql_web_1.print)(document), variables };
|
|
237
237
|
}
|
|
238
238
|
function buildCreateDocument(operationName, mutationField, entityField, select, data, inputTypeName) {
|
|
239
239
|
const selections = select
|
|
@@ -319,7 +319,7 @@ function buildCustomDocument(operationType, operationName, fieldName, select, ar
|
|
|
319
319
|
: [];
|
|
320
320
|
const variableDefs = variableDefinitions.map((definition) => t.variableDefinition({
|
|
321
321
|
variable: t.variable({ name: definition.name }),
|
|
322
|
-
type: (0,
|
|
322
|
+
type: (0, graphql_web_1.parseType)(definition.type),
|
|
323
323
|
}));
|
|
324
324
|
const fieldArgs = variableDefinitions.map((definition) => t.argument({
|
|
325
325
|
name: definition.name,
|
|
@@ -349,7 +349,7 @@ function buildCustomDocument(operationType, operationName, fieldName, select, ar
|
|
|
349
349
|
],
|
|
350
350
|
});
|
|
351
351
|
return {
|
|
352
|
-
document: (0,
|
|
352
|
+
document: (0, graphql_web_1.print)(document),
|
|
353
353
|
variables: (args ?? {}),
|
|
354
354
|
};
|
|
355
355
|
}
|
|
@@ -415,7 +415,7 @@ function buildInputMutationDocument(config) {
|
|
|
415
415
|
variableDefinitions: [
|
|
416
416
|
t.variableDefinition({
|
|
417
417
|
variable: t.variable({ name: 'input' }),
|
|
418
|
-
type: (0,
|
|
418
|
+
type: (0, graphql_web_1.parseType)(config.inputTypeName + '!'),
|
|
419
419
|
}),
|
|
420
420
|
],
|
|
421
421
|
selectionSet: t.selectionSet({
|
|
@@ -437,14 +437,14 @@ function buildInputMutationDocument(config) {
|
|
|
437
437
|
}),
|
|
438
438
|
],
|
|
439
439
|
});
|
|
440
|
-
return (0,
|
|
440
|
+
return (0, graphql_web_1.print)(document);
|
|
441
441
|
}
|
|
442
442
|
function addVariable(spec, definitions, args, variables) {
|
|
443
443
|
if (spec.value === undefined)
|
|
444
444
|
return;
|
|
445
445
|
definitions.push(t.variableDefinition({
|
|
446
446
|
variable: t.variable({ name: spec.varName }),
|
|
447
|
-
type: (0,
|
|
447
|
+
type: (0, graphql_web_1.parseType)(spec.typeName),
|
|
448
448
|
}));
|
|
449
449
|
args.push(t.argument({
|
|
450
450
|
name: spec.argName ?? spec.varName,
|
package/cli/commands/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
export { initCommand, findConfigFile, loadConfigFile } from './init';
|
|
5
5
|
export type { InitOptions, InitResult } from './init';
|
|
6
6
|
export { generateCommand } from './generate';
|
|
7
|
-
export type { GenerateOptions, GenerateResult } from './generate';
|
|
7
|
+
export type { GenerateOptions, GenerateResult, GenerateTargetResult } from './generate';
|
|
8
|
+
export { generateOrmCommand } from './generate-orm';
|
|
9
|
+
export type { GenerateOrmOptions, GenerateOrmResult, GenerateOrmTargetResult } from './generate-orm';
|
package/cli/commands/index.js
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
* CLI commands exports
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateCommand = exports.loadConfigFile = exports.findConfigFile = exports.initCommand = void 0;
|
|
6
|
+
exports.generateOrmCommand = exports.generateCommand = exports.loadConfigFile = exports.findConfigFile = exports.initCommand = void 0;
|
|
7
7
|
var init_1 = require("./init");
|
|
8
8
|
Object.defineProperty(exports, "initCommand", { enumerable: true, get: function () { return init_1.initCommand; } });
|
|
9
9
|
Object.defineProperty(exports, "findConfigFile", { enumerable: true, get: function () { return init_1.findConfigFile; } });
|
|
10
10
|
Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return init_1.loadConfigFile; } });
|
|
11
11
|
var generate_1 = require("./generate");
|
|
12
12
|
Object.defineProperty(exports, "generateCommand", { enumerable: true, get: function () { return generate_1.generateCommand; } });
|
|
13
|
+
var generate_orm_1 = require("./generate-orm");
|
|
14
|
+
Object.defineProperty(exports, "generateOrmCommand", { enumerable: true, get: function () { return generate_orm_1.generateOrmCommand; } });
|
|
@@ -16,39 +16,9 @@ export function generateOrmClientFile() {
|
|
|
16
16
|
* DO NOT EDIT - changes will be overwritten
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
message: string;
|
|
21
|
-
locations?: { line: number; column: number }[];
|
|
22
|
-
path?: (string | number)[];
|
|
23
|
-
extensions?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Discriminated union for query results
|
|
28
|
-
* Use .ok to check success, or use .unwrap() to get data or throw
|
|
29
|
-
*/
|
|
30
|
-
export type QueryResult<T> =
|
|
31
|
-
| { ok: true; data: T; errors: undefined }
|
|
32
|
-
| { ok: false; data: null; errors: GraphQLError[] };
|
|
19
|
+
import type { GraphQLAdapter, GraphQLError, QueryResult } from '@constructive-io/graphql-types';
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
* Pluggable adapter interface for GraphQL execution.
|
|
36
|
-
* Implement this interface to provide custom execution logic (e.g., for testing).
|
|
37
|
-
*/
|
|
38
|
-
export interface GraphQLAdapter {
|
|
39
|
-
/**
|
|
40
|
-
* Execute a GraphQL operation and return the result.
|
|
41
|
-
*/
|
|
42
|
-
execute<T>(document: string, variables?: Record<string, unknown>): Promise<QueryResult<T>>;
|
|
43
|
-
/**
|
|
44
|
-
* Set headers for requests (optional - only implement if adapter supports headers).
|
|
45
|
-
*/
|
|
46
|
-
setHeaders?(headers: Record<string, string>): void;
|
|
47
|
-
/**
|
|
48
|
-
* Get the endpoint URL (optional - only implement if adapter has an endpoint).
|
|
49
|
-
*/
|
|
50
|
-
getEndpoint?(): string;
|
|
51
|
-
}
|
|
21
|
+
export type { GraphQLAdapter, GraphQLError, QueryResult } from '@constructive-io/graphql-types';
|
|
52
22
|
|
|
53
23
|
/**
|
|
54
24
|
* Default adapter that uses fetch for HTTP requests.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Any changes here will affect all generated ORM clients.
|
|
9
9
|
*/
|
|
10
10
|
import * as t from 'gql-ast';
|
|
11
|
-
import { parseType, print } from 'graphql';
|
|
11
|
+
import { parseType, print } from '@0no-co/graphql.web';
|
|
12
12
|
import { GraphQLRequestError } from './client';
|
|
13
13
|
export class QueryBuilder {
|
|
14
14
|
config;
|
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
export { initCommand, findConfigFile, loadConfigFile } from './init';
|
|
5
5
|
export type { InitOptions, InitResult } from './init';
|
|
6
6
|
export { generateCommand } from './generate';
|
|
7
|
-
export type { GenerateOptions, GenerateResult } from './generate';
|
|
7
|
+
export type { GenerateOptions, GenerateResult, GenerateTargetResult } from './generate';
|
|
8
|
+
export { generateOrmCommand } from './generate-orm';
|
|
9
|
+
export type { GenerateOrmOptions, GenerateOrmResult, GenerateOrmTargetResult } from './generate-orm';
|
package/esm/index.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export * from './core';
|
|
|
10
10
|
export * from './generators';
|
|
11
11
|
export * from './client';
|
|
12
12
|
export { defineConfig } from './types/config';
|
|
13
|
+
export { generateCommand, generateOrmCommand, findConfigFile, loadConfigFile, } from './cli/commands';
|
|
14
|
+
export type { GenerateOptions, GenerateResult, GenerateTargetResult, GenerateOrmOptions, GenerateOrmResult, GenerateOrmTargetResult, InitOptions, InitResult, } from './cli/commands';
|
package/esm/index.js
CHANGED
|
@@ -15,3 +15,5 @@ export * from './generators';
|
|
|
15
15
|
export * from './client';
|
|
16
16
|
// Config definition helper
|
|
17
17
|
export { defineConfig } from './types/config';
|
|
18
|
+
// CLI command exports (for packages/cli consumption)
|
|
19
|
+
export { generateCommand, generateOrmCommand, findConfigFile, loadConfigFile, } from './cli/commands';
|
package/index.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export * from './core';
|
|
|
10
10
|
export * from './generators';
|
|
11
11
|
export * from './client';
|
|
12
12
|
export { defineConfig } from './types/config';
|
|
13
|
+
export { generateCommand, generateOrmCommand, findConfigFile, loadConfigFile, } from './cli/commands';
|
|
14
|
+
export type { GenerateOptions, GenerateResult, GenerateTargetResult, GenerateOrmOptions, GenerateOrmResult, GenerateOrmTargetResult, InitOptions, InitResult, } from './cli/commands';
|
package/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.defineConfig = void 0;
|
|
24
|
+
exports.loadConfigFile = exports.findConfigFile = exports.generateOrmCommand = exports.generateCommand = exports.defineConfig = void 0;
|
|
25
25
|
// Core types
|
|
26
26
|
__exportStar(require("./types"), exports);
|
|
27
27
|
// Core query building
|
|
@@ -33,3 +33,9 @@ __exportStar(require("./client"), exports);
|
|
|
33
33
|
// Config definition helper
|
|
34
34
|
var config_1 = require("./types/config");
|
|
35
35
|
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
36
|
+
// CLI command exports (for packages/cli consumption)
|
|
37
|
+
var commands_1 = require("./cli/commands");
|
|
38
|
+
Object.defineProperty(exports, "generateCommand", { enumerable: true, get: function () { return commands_1.generateCommand; } });
|
|
39
|
+
Object.defineProperty(exports, "generateOrmCommand", { enumerable: true, get: function () { return commands_1.generateOrmCommand; } });
|
|
40
|
+
Object.defineProperty(exports, "findConfigFile", { enumerable: true, get: function () { return commands_1.findConfigFile; } });
|
|
41
|
+
Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return commands_1.loadConfigFile; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"description": "CLI-based GraphQL SDK generator for PostGraphile endpoints with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -53,8 +53,10 @@
|
|
|
53
53
|
"example:sdk:typecheck": "tsc --noEmit --jsx react --esModuleInterop --skipLibCheck --moduleResolution node examples/react-hooks-sdk-test.tsx"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"@0no-co/graphql.web": "^1.1.2",
|
|
56
57
|
"@babel/generator": "^7.28.6",
|
|
57
58
|
"@babel/types": "^7.28.6",
|
|
59
|
+
"@constructive-io/graphql-types": "^2.14.0",
|
|
58
60
|
"@inquirerer/utils": "^3.2.0",
|
|
59
61
|
"ajv": "^8.17.1",
|
|
60
62
|
"find-and-require-package-json": "^0.9.0",
|
|
@@ -89,5 +91,5 @@
|
|
|
89
91
|
"tsx": "^4.21.0",
|
|
90
92
|
"typescript": "^5.9.3"
|
|
91
93
|
},
|
|
92
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "57fdad16730e5a09c033ac218c8674e7599db7da"
|
|
93
95
|
}
|