@constructive-io/graphql-codegen 3.2.1 → 3.3.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/index.js +36 -43
- package/cli/shared.d.ts +15 -19
- package/cli/shared.js +104 -25
- package/client/error.js +31 -9
- package/client/execute.js +2 -2
- package/client/index.d.ts +3 -3
- package/client/index.js +6 -6
- package/core/ast.d.ts +1 -1
- package/core/ast.js +1 -1
- package/core/codegen/babel-ast.d.ts +1 -1
- package/core/codegen/babel-ast.js +2 -2
- package/core/codegen/barrel.d.ts +0 -6
- package/core/codegen/barrel.js +22 -19
- package/core/codegen/client.d.ts +2 -12
- package/core/codegen/client.js +7 -21
- package/core/codegen/custom-mutations.d.ts +0 -14
- package/core/codegen/custom-mutations.js +139 -88
- package/core/codegen/custom-queries.d.ts +0 -14
- package/core/codegen/custom-queries.js +483 -193
- package/core/codegen/hooks-ast.d.ts +75 -0
- package/core/codegen/hooks-ast.js +522 -0
- package/core/codegen/index.d.ts +16 -18
- package/core/codegen/index.js +42 -88
- package/core/codegen/invalidation.d.ts +1 -7
- package/core/codegen/invalidation.js +50 -16
- package/core/codegen/mutation-keys.d.ts +1 -10
- package/core/codegen/mutation-keys.js +22 -8
- package/core/codegen/mutations.d.ts +0 -13
- package/core/codegen/mutations.js +301 -366
- package/core/codegen/orm/barrel.d.ts +0 -5
- package/core/codegen/orm/barrel.js +5 -0
- package/core/codegen/orm/client-generator.d.ts +0 -5
- package/core/codegen/orm/client-generator.js +7 -2
- package/core/codegen/orm/client.js +3 -1
- package/core/codegen/orm/custom-ops-generator.d.ts +0 -6
- package/core/codegen/orm/custom-ops-generator.js +104 -51
- package/core/codegen/orm/index.d.ts +4 -4
- package/core/codegen/orm/index.js +28 -15
- package/core/codegen/orm/input-types-generator.d.ts +1 -13
- package/core/codegen/orm/input-types-generator.js +85 -23
- package/core/codegen/orm/model-generator.d.ts +0 -5
- package/core/codegen/orm/model-generator.js +309 -131
- package/core/codegen/orm/select-types.d.ts +19 -14
- package/core/codegen/queries.d.ts +0 -8
- package/core/codegen/queries.js +360 -559
- package/core/codegen/query-keys.d.ts +1 -1
- package/core/codegen/query-keys.js +37 -23
- package/core/codegen/scalars.js +3 -1
- package/core/codegen/schema-types-generator.d.ts +1 -1
- package/core/codegen/schema-types-generator.js +17 -2
- package/core/codegen/select-helpers.d.ts +19 -0
- package/core/codegen/select-helpers.js +40 -0
- package/core/codegen/selection.d.ts +4 -0
- package/core/codegen/selection.js +65 -0
- package/core/codegen/shared/index.d.ts +2 -15
- package/core/codegen/shared/index.js +17 -4
- package/core/codegen/templates/hooks-client.ts +49 -0
- package/core/codegen/templates/hooks-selection.ts +58 -0
- package/core/codegen/templates/orm-client.ts +8 -6
- package/core/codegen/templates/query-builder.ts +250 -46
- package/core/codegen/templates/select-types.ts +31 -14
- package/core/codegen/type-resolver.d.ts +1 -5
- package/core/codegen/type-resolver.js +0 -22
- package/core/codegen/types.d.ts +0 -3
- package/core/codegen/types.js +71 -14
- package/core/codegen/utils.d.ts +1 -4
- package/core/codegen/utils.js +4 -1
- package/core/config/index.d.ts +1 -1
- package/core/config/resolver.js +1 -3
- package/core/generate.js +38 -50
- package/core/index.d.ts +3 -3
- package/core/index.js +3 -4
- package/core/introspect/index.d.ts +6 -6
- package/core/introspect/index.js +5 -8
- package/core/introspect/infer-tables.d.ts +0 -14
- package/core/introspect/infer-tables.js +15 -1
- package/core/introspect/source/database.js +1 -1
- package/core/introspect/source/endpoint.d.ts +0 -6
- package/core/introspect/source/endpoint.js +7 -1
- package/core/introspect/source/index.d.ts +4 -4
- package/core/introspect/source/index.js +5 -9
- package/core/introspect/source/pgpm-module.js +3 -3
- package/core/introspect/transform-schema.d.ts +2 -2
- package/core/introspect/transform-schema.js +2 -2
- package/core/output/index.d.ts +1 -1
- package/core/output/index.js +2 -2
- package/core/output/writer.d.ts +3 -0
- package/core/output/writer.js +20 -1
- package/core/pipeline/index.d.ts +2 -2
- package/core/query-builder.d.ts +2 -2
- package/core/query-builder.js +1 -1
- package/core/watch/index.d.ts +4 -4
- package/core/watch/index.js +9 -9
- package/core/watch/orchestrator.js +5 -3
- package/esm/cli/index.js +37 -44
- package/esm/cli/shared.d.ts +15 -19
- package/esm/cli/shared.js +94 -23
- package/esm/client/error.js +31 -9
- package/esm/client/execute.js +2 -2
- package/esm/client/index.d.ts +3 -3
- package/esm/client/index.js +3 -3
- package/esm/core/ast.d.ts +1 -1
- package/esm/core/ast.js +1 -1
- package/esm/core/codegen/babel-ast.d.ts +1 -1
- package/esm/core/codegen/babel-ast.js +2 -2
- package/esm/core/codegen/barrel.d.ts +0 -6
- package/esm/core/codegen/barrel.js +23 -20
- package/esm/core/codegen/client.d.ts +2 -12
- package/esm/core/codegen/client.js +7 -21
- package/esm/core/codegen/custom-mutations.d.ts +0 -14
- package/esm/core/codegen/custom-mutations.js +141 -90
- package/esm/core/codegen/custom-queries.d.ts +0 -14
- package/esm/core/codegen/custom-queries.js +486 -196
- package/esm/core/codegen/hooks-ast.d.ts +75 -0
- package/esm/core/codegen/hooks-ast.js +424 -0
- package/esm/core/codegen/index.d.ts +16 -18
- package/esm/core/codegen/index.js +26 -71
- package/esm/core/codegen/invalidation.d.ts +1 -7
- package/esm/core/codegen/invalidation.js +51 -17
- package/esm/core/codegen/mutation-keys.d.ts +1 -10
- package/esm/core/codegen/mutation-keys.js +23 -9
- package/esm/core/codegen/mutations.d.ts +0 -13
- package/esm/core/codegen/mutations.js +302 -367
- package/esm/core/codegen/orm/barrel.d.ts +0 -5
- package/esm/core/codegen/orm/barrel.js +6 -1
- package/esm/core/codegen/orm/client-generator.d.ts +0 -5
- package/esm/core/codegen/orm/client-generator.js +7 -2
- package/esm/core/codegen/orm/client.js +3 -1
- package/esm/core/codegen/orm/custom-ops-generator.d.ts +0 -6
- package/esm/core/codegen/orm/custom-ops-generator.js +103 -50
- package/esm/core/codegen/orm/index.d.ts +4 -4
- package/esm/core/codegen/orm/index.js +25 -12
- package/esm/core/codegen/orm/input-types-generator.d.ts +1 -13
- package/esm/core/codegen/orm/input-types-generator.js +85 -23
- package/esm/core/codegen/orm/model-generator.d.ts +0 -5
- package/esm/core/codegen/orm/model-generator.js +310 -132
- package/esm/core/codegen/orm/select-types.d.ts +19 -14
- package/esm/core/codegen/queries.d.ts +0 -8
- package/esm/core/codegen/queries.js +362 -561
- package/esm/core/codegen/query-keys.d.ts +1 -1
- package/esm/core/codegen/query-keys.js +38 -24
- package/esm/core/codegen/scalars.js +3 -1
- package/esm/core/codegen/schema-types-generator.d.ts +1 -1
- package/esm/core/codegen/schema-types-generator.js +17 -2
- package/esm/core/codegen/select-helpers.d.ts +19 -0
- package/esm/core/codegen/select-helpers.js +35 -0
- package/esm/core/codegen/selection.d.ts +4 -0
- package/esm/core/codegen/selection.js +29 -0
- package/esm/core/codegen/shared/index.d.ts +2 -15
- package/esm/core/codegen/shared/index.js +16 -3
- package/esm/core/codegen/type-resolver.d.ts +1 -5
- package/esm/core/codegen/type-resolver.js +1 -22
- package/esm/core/codegen/types.d.ts +0 -3
- package/esm/core/codegen/types.js +72 -15
- package/esm/core/codegen/utils.d.ts +1 -4
- package/esm/core/codegen/utils.js +4 -1
- package/esm/core/config/index.d.ts +1 -1
- package/esm/core/config/resolver.js +2 -4
- package/esm/core/generate.js +38 -50
- package/esm/core/index.d.ts +3 -3
- package/esm/core/index.js +2 -3
- package/esm/core/introspect/index.d.ts +6 -6
- package/esm/core/introspect/index.js +3 -6
- package/esm/core/introspect/infer-tables.d.ts +0 -14
- package/esm/core/introspect/infer-tables.js +16 -2
- package/esm/core/introspect/source/database.js +2 -2
- package/esm/core/introspect/source/endpoint.d.ts +0 -6
- package/esm/core/introspect/source/endpoint.js +7 -1
- package/esm/core/introspect/source/index.d.ts +4 -4
- package/esm/core/introspect/source/index.js +6 -10
- package/esm/core/introspect/source/pgpm-module.js +3 -3
- package/esm/core/introspect/transform-schema.d.ts +2 -2
- package/esm/core/introspect/transform-schema.js +2 -2
- package/esm/core/output/index.d.ts +1 -1
- package/esm/core/output/index.js +1 -1
- package/esm/core/output/writer.d.ts +3 -0
- package/esm/core/output/writer.js +20 -1
- package/esm/core/pipeline/index.d.ts +2 -2
- package/esm/core/pipeline/index.js +2 -2
- package/esm/core/query-builder.d.ts +2 -2
- package/esm/core/query-builder.js +2 -2
- package/esm/core/watch/index.d.ts +4 -4
- package/esm/core/watch/index.js +3 -3
- package/esm/core/watch/orchestrator.js +5 -3
- package/esm/generators/index.d.ts +3 -3
- package/esm/generators/index.js +3 -3
- package/esm/generators/mutations.d.ts +1 -1
- package/esm/generators/select.d.ts +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js +1 -4
- package/esm/types/config.d.ts +0 -10
- package/esm/types/config.js +0 -2
- package/esm/types/index.d.ts +6 -6
- package/esm/types/index.js +1 -1
- package/generators/index.d.ts +3 -3
- package/generators/index.js +8 -8
- package/generators/mutations.d.ts +1 -1
- package/generators/select.d.ts +1 -1
- package/index.d.ts +3 -3
- package/index.js +11 -6
- package/package.json +10 -10
- package/types/config.d.ts +0 -10
- package/types/config.js +0 -2
- package/types/index.d.ts +6 -6
- package/types/index.js +2 -2
- package/core/codegen/gql-ast.d.ts +0 -41
- package/core/codegen/gql-ast.js +0 -353
- package/core/codegen/schema-gql-ast.d.ts +0 -51
- package/core/codegen/schema-gql-ast.js +0 -385
- package/core/codegen/templates/client.browser.ts +0 -271
- package/core/codegen/templates/client.node.ts +0 -337
- package/esm/core/codegen/gql-ast.d.ts +0 -41
- package/esm/core/codegen/gql-ast.js +0 -312
- package/esm/core/codegen/schema-gql-ast.d.ts +0 -51
- package/esm/core/codegen/schema-gql-ast.js +0 -343
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TypedDocumentString } from '../client/typed-document';
|
|
2
2
|
import { QueryBuilder } from '../core/query-builder';
|
|
3
3
|
import type { IntrospectionSchema, MetaObject } from '../core/types';
|
|
4
|
-
import type { CleanTable } from '../types/schema';
|
|
5
4
|
import type { QueryOptions } from '../types/query';
|
|
5
|
+
import type { CleanTable } from '../types/schema';
|
|
6
6
|
/**
|
|
7
7
|
* Convert PascalCase table name to camelCase plural for GraphQL queries
|
|
8
8
|
* Uses the inflection library for proper pluralization
|
package/esm/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export * from './core';
|
|
|
10
10
|
export * from './generators';
|
|
11
11
|
export * from './client';
|
|
12
12
|
export { defineConfig } from './types/config';
|
|
13
|
-
export { generate } from './core/generate';
|
|
14
13
|
export type { GenerateOptions, GenerateResult } from './core/generate';
|
|
14
|
+
export { generate } from './core/generate';
|
|
15
15
|
export { findConfigFile, loadConfigFile } from './core/config';
|
|
16
|
-
export { codegenQuestions, splitCommas, printResult, camelizeArgv } from './cli/shared';
|
|
17
16
|
export type { CodegenAnswers } from './cli/shared';
|
|
18
|
-
export {
|
|
17
|
+
export { buildDbConfig, buildGenerateOptions, camelizeArgv, codegenQuestions, filterDefined, flattenDbFields, hasResolvedCodegenSource, hyphenateKeys, normalizeCodegenListOptions, printResult, seedArgvFromConfig, splitCommas, } from './cli/shared';
|
|
19
18
|
export type { BuildSchemaFromDatabaseOptions, BuildSchemaFromDatabaseResult, } from './core/database';
|
|
19
|
+
export { buildSchemaFromDatabase, buildSchemaSDLFromDatabase, } from './core/database';
|
package/esm/index.js
CHANGED
|
@@ -15,11 +15,8 @@ export * from './generators';
|
|
|
15
15
|
export * from './client';
|
|
16
16
|
// Config definition helper
|
|
17
17
|
export { defineConfig } from './types/config';
|
|
18
|
-
// Main generate function (orchestrates the entire pipeline)
|
|
19
18
|
export { generate } from './core/generate';
|
|
20
19
|
// Config utilities
|
|
21
20
|
export { findConfigFile, loadConfigFile } from './core/config';
|
|
22
|
-
|
|
23
|
-
export { codegenQuestions, splitCommas, printResult, camelizeArgv } from './cli/shared';
|
|
24
|
-
// Database schema utilities (re-exported from core for convenience)
|
|
21
|
+
export { buildDbConfig, buildGenerateOptions, camelizeArgv, codegenQuestions, filterDefined, flattenDbFields, hasResolvedCodegenSource, hyphenateKeys, normalizeCodegenListOptions, printResult, seedArgvFromConfig, splitCommas, } from './cli/shared';
|
|
25
22
|
export { buildSchemaFromDatabase, buildSchemaSDLFromDatabase, } from './core/database';
|
package/esm/types/config.d.ts
CHANGED
|
@@ -205,8 +205,6 @@ export interface GraphQLSDKConfigTarget {
|
|
|
205
205
|
* Code generation options
|
|
206
206
|
*/
|
|
207
207
|
codegen?: {
|
|
208
|
-
/** Max depth for nested object field selection (default: 2) */
|
|
209
|
-
maxFieldDepth?: number;
|
|
210
208
|
/** Skip 'query' field on mutation payloads (default: true) */
|
|
211
209
|
skipQueryField?: boolean;
|
|
212
210
|
};
|
|
@@ -223,14 +221,6 @@ export interface GraphQLSDKConfigTarget {
|
|
|
223
221
|
* @default false
|
|
224
222
|
*/
|
|
225
223
|
reactQuery?: boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Generate browser-compatible code using native fetch
|
|
228
|
-
* When true (default), uses native W3C fetch API (works in browsers and Node.js)
|
|
229
|
-
* When false, uses undici fetch with dispatcher support for localhost DNS resolution
|
|
230
|
-
* (Node.js only - enables proper *.localhost subdomain resolution on macOS)
|
|
231
|
-
* @default true
|
|
232
|
-
*/
|
|
233
|
-
browserCompatible?: boolean;
|
|
234
224
|
/**
|
|
235
225
|
* Query key generation configuration
|
|
236
226
|
* Controls how query keys are structured for cache management
|
package/esm/types/config.js
CHANGED
|
@@ -59,12 +59,10 @@ export const DEFAULT_CONFIG = {
|
|
|
59
59
|
schema: 'public',
|
|
60
60
|
},
|
|
61
61
|
codegen: {
|
|
62
|
-
maxFieldDepth: 2,
|
|
63
62
|
skipQueryField: true,
|
|
64
63
|
},
|
|
65
64
|
orm: false,
|
|
66
65
|
reactQuery: false,
|
|
67
|
-
browserCompatible: true,
|
|
68
66
|
queryKeys: DEFAULT_QUERY_KEY_CONFIG,
|
|
69
67
|
watch: DEFAULT_WATCH_CONFIG,
|
|
70
68
|
};
|
package/esm/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type exports for @constructive-io/graphql-codegen
|
|
3
3
|
*/
|
|
4
|
-
export type {
|
|
5
|
-
export type {
|
|
6
|
-
export type {
|
|
7
|
-
export type {
|
|
8
|
-
export type { GraphQLSDKConfig, GraphQLSDKConfigTarget
|
|
9
|
-
export { defineConfig, getConfigOptions, mergeConfig,
|
|
4
|
+
export type { CleanBelongsToRelation, CleanField, CleanFieldType, CleanHasManyRelation, CleanHasOneRelation, CleanManyToManyRelation, CleanRelations, CleanTable, ConstraintInfo, ForeignKeyConstraint, TableConstraints, TableInflection, TableQueryNames, } from './schema';
|
|
5
|
+
export type { ConnectionResult, FieldFilter, Filter, FilterOperator, OrderByItem, PageInfo, QueryOptions, RelationalFilter, } from './query';
|
|
6
|
+
export type { CreateInput, DeleteInput, MutationOptions, MutationResult, UpdateInput, } from './mutation';
|
|
7
|
+
export type { FieldSelection, FieldSelectionPreset, SelectionOptions, SimpleFieldSelection, } from './selection';
|
|
8
|
+
export type { GraphQLSDKConfig, GraphQLSDKConfigTarget } from './config';
|
|
9
|
+
export { DEFAULT_CONFIG, defineConfig, getConfigOptions, mergeConfig, } from './config';
|
package/esm/types/index.js
CHANGED
package/generators/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Query and mutation generator exports
|
|
3
3
|
*/
|
|
4
|
-
export { convertToSelectionOptions,
|
|
5
|
-
export {
|
|
6
|
-
export { buildPostGraphileCreate,
|
|
4
|
+
export { convertToSelectionOptions, getAvailableRelations, isRelationalField, validateFieldSelection, } from './field-selector';
|
|
5
|
+
export { buildCount, buildFindOne, buildSelect, cleanTableToMetaObject, createASTQueryBuilder, generateIntrospectionSchema, toCamelCasePlural, toOrderByTypeName, } from './select';
|
|
6
|
+
export { buildPostGraphileCreate, buildPostGraphileDelete, buildPostGraphileUpdate, } from './mutations';
|
package/generators/index.js
CHANGED
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
* Query and mutation generator exports
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.buildPostGraphileUpdate = exports.buildPostGraphileDelete = exports.buildPostGraphileCreate = exports.toOrderByTypeName = exports.toCamelCasePlural = exports.generateIntrospectionSchema = exports.createASTQueryBuilder = exports.cleanTableToMetaObject = exports.buildSelect = exports.buildFindOne = exports.buildCount = exports.validateFieldSelection = exports.isRelationalField = exports.getAvailableRelations = exports.convertToSelectionOptions = void 0;
|
|
7
7
|
// Field selector utilities
|
|
8
8
|
var field_selector_1 = require("./field-selector");
|
|
9
9
|
Object.defineProperty(exports, "convertToSelectionOptions", { enumerable: true, get: function () { return field_selector_1.convertToSelectionOptions; } });
|
|
10
|
-
Object.defineProperty(exports, "isRelationalField", { enumerable: true, get: function () { return field_selector_1.isRelationalField; } });
|
|
11
10
|
Object.defineProperty(exports, "getAvailableRelations", { enumerable: true, get: function () { return field_selector_1.getAvailableRelations; } });
|
|
11
|
+
Object.defineProperty(exports, "isRelationalField", { enumerable: true, get: function () { return field_selector_1.isRelationalField; } });
|
|
12
12
|
Object.defineProperty(exports, "validateFieldSelection", { enumerable: true, get: function () { return field_selector_1.validateFieldSelection; } });
|
|
13
13
|
// Query generators
|
|
14
14
|
var select_1 = require("./select");
|
|
15
|
-
Object.defineProperty(exports, "buildSelect", { enumerable: true, get: function () { return select_1.buildSelect; } });
|
|
16
|
-
Object.defineProperty(exports, "buildFindOne", { enumerable: true, get: function () { return select_1.buildFindOne; } });
|
|
17
15
|
Object.defineProperty(exports, "buildCount", { enumerable: true, get: function () { return select_1.buildCount; } });
|
|
18
|
-
Object.defineProperty(exports, "
|
|
19
|
-
Object.defineProperty(exports, "
|
|
16
|
+
Object.defineProperty(exports, "buildFindOne", { enumerable: true, get: function () { return select_1.buildFindOne; } });
|
|
17
|
+
Object.defineProperty(exports, "buildSelect", { enumerable: true, get: function () { return select_1.buildSelect; } });
|
|
20
18
|
Object.defineProperty(exports, "cleanTableToMetaObject", { enumerable: true, get: function () { return select_1.cleanTableToMetaObject; } });
|
|
21
|
-
Object.defineProperty(exports, "generateIntrospectionSchema", { enumerable: true, get: function () { return select_1.generateIntrospectionSchema; } });
|
|
22
19
|
Object.defineProperty(exports, "createASTQueryBuilder", { enumerable: true, get: function () { return select_1.createASTQueryBuilder; } });
|
|
20
|
+
Object.defineProperty(exports, "generateIntrospectionSchema", { enumerable: true, get: function () { return select_1.generateIntrospectionSchema; } });
|
|
21
|
+
Object.defineProperty(exports, "toCamelCasePlural", { enumerable: true, get: function () { return select_1.toCamelCasePlural; } });
|
|
22
|
+
Object.defineProperty(exports, "toOrderByTypeName", { enumerable: true, get: function () { return select_1.toOrderByTypeName; } });
|
|
23
23
|
// Mutation generators
|
|
24
24
|
var mutations_1 = require("./mutations");
|
|
25
25
|
Object.defineProperty(exports, "buildPostGraphileCreate", { enumerable: true, get: function () { return mutations_1.buildPostGraphileCreate; } });
|
|
26
|
-
Object.defineProperty(exports, "buildPostGraphileUpdate", { enumerable: true, get: function () { return mutations_1.buildPostGraphileUpdate; } });
|
|
27
26
|
Object.defineProperty(exports, "buildPostGraphileDelete", { enumerable: true, get: function () { return mutations_1.buildPostGraphileDelete; } });
|
|
27
|
+
Object.defineProperty(exports, "buildPostGraphileUpdate", { enumerable: true, get: function () { return mutations_1.buildPostGraphileUpdate; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TypedDocumentString } from '../client/typed-document';
|
|
2
|
-
import type { CleanTable } from '../types/schema';
|
|
3
2
|
import type { MutationOptions } from '../types/mutation';
|
|
3
|
+
import type { CleanTable } from '../types/schema';
|
|
4
4
|
/**
|
|
5
5
|
* Build PostGraphile-style CREATE mutation
|
|
6
6
|
* PostGraphile expects: mutation { createTableName(input: { tableName: TableNameInput! }) { tableName { ... } } }
|
package/generators/select.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TypedDocumentString } from '../client/typed-document';
|
|
2
2
|
import { QueryBuilder } from '../core/query-builder';
|
|
3
3
|
import type { IntrospectionSchema, MetaObject } from '../core/types';
|
|
4
|
-
import type { CleanTable } from '../types/schema';
|
|
5
4
|
import type { QueryOptions } from '../types/query';
|
|
5
|
+
import type { CleanTable } from '../types/schema';
|
|
6
6
|
/**
|
|
7
7
|
* Convert PascalCase table name to camelCase plural for GraphQL queries
|
|
8
8
|
* Uses the inflection library for proper pluralization
|
package/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export * from './core';
|
|
|
10
10
|
export * from './generators';
|
|
11
11
|
export * from './client';
|
|
12
12
|
export { defineConfig } from './types/config';
|
|
13
|
-
export { generate } from './core/generate';
|
|
14
13
|
export type { GenerateOptions, GenerateResult } from './core/generate';
|
|
14
|
+
export { generate } from './core/generate';
|
|
15
15
|
export { findConfigFile, loadConfigFile } from './core/config';
|
|
16
|
-
export { codegenQuestions, splitCommas, printResult, camelizeArgv } from './cli/shared';
|
|
17
16
|
export type { CodegenAnswers } from './cli/shared';
|
|
18
|
-
export {
|
|
17
|
+
export { buildDbConfig, buildGenerateOptions, camelizeArgv, codegenQuestions, filterDefined, flattenDbFields, hasResolvedCodegenSource, hyphenateKeys, normalizeCodegenListOptions, printResult, seedArgvFromConfig, splitCommas, } from './cli/shared';
|
|
19
18
|
export type { BuildSchemaFromDatabaseOptions, BuildSchemaFromDatabaseResult, } from './core/database';
|
|
19
|
+
export { buildSchemaFromDatabase, buildSchemaSDLFromDatabase, } from './core/database';
|
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.buildSchemaSDLFromDatabase = exports.buildSchemaFromDatabase = exports.
|
|
24
|
+
exports.buildSchemaSDLFromDatabase = exports.buildSchemaFromDatabase = exports.splitCommas = exports.seedArgvFromConfig = exports.printResult = exports.normalizeCodegenListOptions = exports.hyphenateKeys = exports.hasResolvedCodegenSource = exports.flattenDbFields = exports.filterDefined = exports.codegenQuestions = exports.camelizeArgv = exports.buildGenerateOptions = exports.buildDbConfig = exports.loadConfigFile = exports.findConfigFile = exports.generate = exports.defineConfig = void 0;
|
|
25
25
|
// Core types
|
|
26
26
|
__exportStar(require("./types"), exports);
|
|
27
27
|
// Core query building
|
|
@@ -33,20 +33,25 @@ __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
|
-
// Main generate function (orchestrates the entire pipeline)
|
|
37
36
|
var generate_1 = require("./core/generate");
|
|
38
37
|
Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return generate_1.generate; } });
|
|
39
38
|
// Config utilities
|
|
40
39
|
var config_2 = require("./core/config");
|
|
41
40
|
Object.defineProperty(exports, "findConfigFile", { enumerable: true, get: function () { return config_2.findConfigFile; } });
|
|
42
41
|
Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return config_2.loadConfigFile; } });
|
|
43
|
-
// CLI shared utilities (for packages/cli to import)
|
|
44
42
|
var shared_1 = require("./cli/shared");
|
|
43
|
+
Object.defineProperty(exports, "buildDbConfig", { enumerable: true, get: function () { return shared_1.buildDbConfig; } });
|
|
44
|
+
Object.defineProperty(exports, "buildGenerateOptions", { enumerable: true, get: function () { return shared_1.buildGenerateOptions; } });
|
|
45
|
+
Object.defineProperty(exports, "camelizeArgv", { enumerable: true, get: function () { return shared_1.camelizeArgv; } });
|
|
45
46
|
Object.defineProperty(exports, "codegenQuestions", { enumerable: true, get: function () { return shared_1.codegenQuestions; } });
|
|
46
|
-
Object.defineProperty(exports, "
|
|
47
|
+
Object.defineProperty(exports, "filterDefined", { enumerable: true, get: function () { return shared_1.filterDefined; } });
|
|
48
|
+
Object.defineProperty(exports, "flattenDbFields", { enumerable: true, get: function () { return shared_1.flattenDbFields; } });
|
|
49
|
+
Object.defineProperty(exports, "hasResolvedCodegenSource", { enumerable: true, get: function () { return shared_1.hasResolvedCodegenSource; } });
|
|
50
|
+
Object.defineProperty(exports, "hyphenateKeys", { enumerable: true, get: function () { return shared_1.hyphenateKeys; } });
|
|
51
|
+
Object.defineProperty(exports, "normalizeCodegenListOptions", { enumerable: true, get: function () { return shared_1.normalizeCodegenListOptions; } });
|
|
47
52
|
Object.defineProperty(exports, "printResult", { enumerable: true, get: function () { return shared_1.printResult; } });
|
|
48
|
-
Object.defineProperty(exports, "
|
|
49
|
-
|
|
53
|
+
Object.defineProperty(exports, "seedArgvFromConfig", { enumerable: true, get: function () { return shared_1.seedArgvFromConfig; } });
|
|
54
|
+
Object.defineProperty(exports, "splitCommas", { enumerable: true, get: function () { return shared_1.splitCommas; } });
|
|
50
55
|
var database_1 = require("./core/database");
|
|
51
56
|
Object.defineProperty(exports, "buildSchemaFromDatabase", { enumerable: true, get: function () { return database_1.buildSchemaFromDatabase; } });
|
|
52
57
|
Object.defineProperty(exports, "buildSchemaSDLFromDatabase", { enumerable: true, get: function () { return database_1.buildSchemaSDLFromDatabase; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -56,23 +56,23 @@
|
|
|
56
56
|
"@0no-co/graphql.web": "^1.1.2",
|
|
57
57
|
"@babel/generator": "^7.28.6",
|
|
58
58
|
"@babel/types": "^7.28.6",
|
|
59
|
-
"@constructive-io/graphql-server": "^3.0
|
|
60
|
-
"@constructive-io/graphql-types": "^2.
|
|
59
|
+
"@constructive-io/graphql-server": "^3.1.0",
|
|
60
|
+
"@constructive-io/graphql-types": "^2.15.0",
|
|
61
61
|
"@inquirerer/utils": "^3.2.0",
|
|
62
|
-
"@pgpmjs/core": "^5.
|
|
62
|
+
"@pgpmjs/core": "^5.2.0",
|
|
63
63
|
"ajv": "^8.17.1",
|
|
64
64
|
"deepmerge": "^4.3.1",
|
|
65
65
|
"find-and-require-package-json": "^0.9.0",
|
|
66
|
-
"gql-ast": "^2.
|
|
66
|
+
"gql-ast": "^2.7.0",
|
|
67
67
|
"graphql": "15.10.1",
|
|
68
68
|
"inflekt": "^0.3.1",
|
|
69
69
|
"inquirerer": "^4.4.0",
|
|
70
70
|
"jiti": "^2.6.1",
|
|
71
71
|
"oxfmt": "^0.26.0",
|
|
72
|
-
"pg-cache": "^2.
|
|
73
|
-
"pg-env": "^1.
|
|
74
|
-
"pgsql-client": "^2.0
|
|
75
|
-
"pgsql-seed": "^1.0
|
|
72
|
+
"pg-cache": "^2.1.0",
|
|
73
|
+
"pg-env": "^1.4.0",
|
|
74
|
+
"pgsql-client": "^2.1.0",
|
|
75
|
+
"pgsql-seed": "^1.1.0",
|
|
76
76
|
"undici": "^7.19.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
"tsx": "^4.21.0",
|
|
100
100
|
"typescript": "^5.9.3"
|
|
101
101
|
},
|
|
102
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "048188f6b43ffaa6146e7694b2b0d35d34cb2945"
|
|
103
103
|
}
|
package/types/config.d.ts
CHANGED
|
@@ -205,8 +205,6 @@ export interface GraphQLSDKConfigTarget {
|
|
|
205
205
|
* Code generation options
|
|
206
206
|
*/
|
|
207
207
|
codegen?: {
|
|
208
|
-
/** Max depth for nested object field selection (default: 2) */
|
|
209
|
-
maxFieldDepth?: number;
|
|
210
208
|
/** Skip 'query' field on mutation payloads (default: true) */
|
|
211
209
|
skipQueryField?: boolean;
|
|
212
210
|
};
|
|
@@ -223,14 +221,6 @@ export interface GraphQLSDKConfigTarget {
|
|
|
223
221
|
* @default false
|
|
224
222
|
*/
|
|
225
223
|
reactQuery?: boolean;
|
|
226
|
-
/**
|
|
227
|
-
* Generate browser-compatible code using native fetch
|
|
228
|
-
* When true (default), uses native W3C fetch API (works in browsers and Node.js)
|
|
229
|
-
* When false, uses undici fetch with dispatcher support for localhost DNS resolution
|
|
230
|
-
* (Node.js only - enables proper *.localhost subdomain resolution on macOS)
|
|
231
|
-
* @default true
|
|
232
|
-
*/
|
|
233
|
-
browserCompatible?: boolean;
|
|
234
224
|
/**
|
|
235
225
|
* Query key generation configuration
|
|
236
226
|
* Controls how query keys are structured for cache management
|
package/types/config.js
CHANGED
|
@@ -68,12 +68,10 @@ exports.DEFAULT_CONFIG = {
|
|
|
68
68
|
schema: 'public',
|
|
69
69
|
},
|
|
70
70
|
codegen: {
|
|
71
|
-
maxFieldDepth: 2,
|
|
72
71
|
skipQueryField: true,
|
|
73
72
|
},
|
|
74
73
|
orm: false,
|
|
75
74
|
reactQuery: false,
|
|
76
|
-
browserCompatible: true,
|
|
77
75
|
queryKeys: exports.DEFAULT_QUERY_KEY_CONFIG,
|
|
78
76
|
watch: exports.DEFAULT_WATCH_CONFIG,
|
|
79
77
|
};
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type exports for @constructive-io/graphql-codegen
|
|
3
3
|
*/
|
|
4
|
-
export type {
|
|
5
|
-
export type {
|
|
6
|
-
export type {
|
|
7
|
-
export type {
|
|
8
|
-
export type { GraphQLSDKConfig, GraphQLSDKConfigTarget
|
|
9
|
-
export { defineConfig, getConfigOptions, mergeConfig,
|
|
4
|
+
export type { CleanBelongsToRelation, CleanField, CleanFieldType, CleanHasManyRelation, CleanHasOneRelation, CleanManyToManyRelation, CleanRelations, CleanTable, ConstraintInfo, ForeignKeyConstraint, TableConstraints, TableInflection, TableQueryNames, } from './schema';
|
|
5
|
+
export type { ConnectionResult, FieldFilter, Filter, FilterOperator, OrderByItem, PageInfo, QueryOptions, RelationalFilter, } from './query';
|
|
6
|
+
export type { CreateInput, DeleteInput, MutationOptions, MutationResult, UpdateInput, } from './mutation';
|
|
7
|
+
export type { FieldSelection, FieldSelectionPreset, SelectionOptions, SimpleFieldSelection, } from './selection';
|
|
8
|
+
export type { GraphQLSDKConfig, GraphQLSDKConfigTarget } from './config';
|
|
9
|
+
export { DEFAULT_CONFIG, defineConfig, getConfigOptions, mergeConfig, } from './config';
|
package/types/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Type exports for @constructive-io/graphql-codegen
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.mergeConfig = exports.getConfigOptions = exports.defineConfig = exports.DEFAULT_CONFIG = void 0;
|
|
7
7
|
var config_1 = require("./config");
|
|
8
|
+
Object.defineProperty(exports, "DEFAULT_CONFIG", { enumerable: true, get: function () { return config_1.DEFAULT_CONFIG; } });
|
|
8
9
|
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
9
10
|
Object.defineProperty(exports, "getConfigOptions", { enumerable: true, get: function () { return config_1.getConfigOptions; } });
|
|
10
11
|
Object.defineProperty(exports, "mergeConfig", { enumerable: true, get: function () { return config_1.mergeConfig; } });
|
|
11
|
-
Object.defineProperty(exports, "DEFAULT_CONFIG", { enumerable: true, get: function () { return config_1.DEFAULT_CONFIG; } });
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from 'graphql';
|
|
2
|
-
import type { CleanTable } from '../../types/schema';
|
|
3
|
-
export interface ListQueryConfig {
|
|
4
|
-
table: CleanTable;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Build a list query AST for a table
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildListQueryAST(config: ListQueryConfig): DocumentNode;
|
|
10
|
-
export interface SingleQueryConfig {
|
|
11
|
-
table: CleanTable;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Build a single item query AST for a table
|
|
15
|
-
*/
|
|
16
|
-
export declare function buildSingleQueryAST(config: SingleQueryConfig): DocumentNode;
|
|
17
|
-
export interface CreateMutationConfig {
|
|
18
|
-
table: CleanTable;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build a create mutation AST for a table
|
|
22
|
-
*/
|
|
23
|
-
export declare function buildCreateMutationAST(config: CreateMutationConfig): DocumentNode;
|
|
24
|
-
export interface UpdateMutationConfig {
|
|
25
|
-
table: CleanTable;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Build an update mutation AST for a table
|
|
29
|
-
*/
|
|
30
|
-
export declare function buildUpdateMutationAST(config: UpdateMutationConfig): DocumentNode;
|
|
31
|
-
export interface DeleteMutationConfig {
|
|
32
|
-
table: CleanTable;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Build a delete mutation AST for a table
|
|
36
|
-
*/
|
|
37
|
-
export declare function buildDeleteMutationAST(config: DeleteMutationConfig): DocumentNode;
|
|
38
|
-
/**
|
|
39
|
-
* Print AST to GraphQL string
|
|
40
|
-
*/
|
|
41
|
-
export declare function printGraphQL(ast: DocumentNode): string;
|