@constructive-io/graphql-codegen 4.6.1 → 4.7.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/client/error.d.ts +2 -93
- package/client/error.js +9 -273
- package/client/execute.d.ts +2 -55
- package/client/execute.js +5 -120
- package/client/typed-document.d.ts +2 -29
- package/client/typed-document.js +3 -39
- package/core/ast.d.ts +8 -10
- package/core/ast.js +17 -592
- package/core/custom-ast.d.ts +5 -33
- package/core/custom-ast.js +16 -203
- package/core/introspect/infer-tables.d.ts +2 -40
- package/core/introspect/infer-tables.js +4 -696
- package/core/introspect/schema-query.d.ts +3 -18
- package/core/introspect/schema-query.js +3 -118
- package/core/introspect/transform-schema.d.ts +2 -84
- package/core/introspect/transform-schema.js +14 -279
- package/core/introspect/transform.d.ts +2 -18
- package/core/introspect/transform.js +6 -39
- package/core/meta-object/convert.d.ts +2 -63
- package/core/meta-object/convert.js +4 -59
- package/core/meta-object/validate.d.ts +2 -7
- package/core/meta-object/validate.js +4 -30
- package/core/query-builder.d.ts +7 -46
- package/core/query-builder.js +8 -408
- package/core/types.d.ts +9 -139
- package/core/types.js +12 -26
- package/esm/client/error.d.ts +2 -93
- package/esm/client/error.js +2 -269
- package/esm/client/execute.d.ts +2 -55
- package/esm/client/execute.js +2 -118
- package/esm/client/typed-document.d.ts +2 -29
- package/esm/client/typed-document.js +2 -38
- package/esm/core/ast.d.ts +8 -10
- package/esm/core/ast.js +8 -550
- package/esm/core/custom-ast.d.ts +5 -33
- package/esm/core/custom-ast.js +5 -160
- package/esm/core/introspect/infer-tables.d.ts +2 -40
- package/esm/core/introspect/infer-tables.js +2 -695
- package/esm/core/introspect/schema-query.d.ts +3 -18
- package/esm/core/introspect/schema-query.js +2 -118
- package/esm/core/introspect/transform-schema.d.ts +2 -84
- package/esm/core/introspect/transform-schema.js +2 -269
- package/esm/core/introspect/transform.d.ts +2 -18
- package/esm/core/introspect/transform.js +2 -36
- package/esm/core/meta-object/convert.d.ts +2 -63
- package/esm/core/meta-object/convert.js +2 -58
- package/esm/core/meta-object/validate.d.ts +2 -7
- package/esm/core/meta-object/validate.js +2 -26
- package/esm/core/query-builder.d.ts +7 -46
- package/esm/core/query-builder.js +5 -373
- package/esm/core/types.d.ts +9 -139
- package/esm/core/types.js +9 -24
- package/esm/generators/field-selector.d.ts +5 -28
- package/esm/generators/field-selector.js +5 -379
- package/esm/generators/mutations.d.ts +5 -28
- package/esm/generators/mutations.js +5 -198
- package/esm/generators/naming-helpers.d.ts +3 -45
- package/esm/generators/naming-helpers.js +3 -151
- package/esm/generators/select.d.ts +6 -37
- package/esm/generators/select.js +6 -659
- package/generators/field-selector.d.ts +5 -28
- package/generators/field-selector.js +12 -385
- package/generators/mutations.d.ts +5 -28
- package/generators/mutations.js +9 -234
- package/generators/naming-helpers.d.ts +3 -45
- package/generators/naming-helpers.js +15 -164
- package/generators/select.d.ts +6 -37
- package/generators/select.js +17 -703
- package/package.json +7 -6
- package/core/meta-object/format.json +0 -93
- package/esm/core/meta-object/format.json +0 -93
package/core/custom-ast.js
CHANGED
|
@@ -1,205 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getCustomAst =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
const { pgType } = fieldDefn.type;
|
|
54
|
-
if (pgType === 'geometry') {
|
|
55
|
-
return geometryAst(fieldDefn.name);
|
|
56
|
-
}
|
|
57
|
-
if (pgType === 'interval') {
|
|
58
|
-
return intervalAst(fieldDefn.name);
|
|
59
|
-
}
|
|
60
|
-
return t.field({
|
|
61
|
-
name: fieldDefn.name,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Generate custom AST for CleanField type - handles GraphQL types that need subfield selections
|
|
66
|
-
*/
|
|
67
|
-
function getCustomAstForCleanField(field) {
|
|
68
|
-
const { name, type } = field;
|
|
69
|
-
const { gqlType, pgType } = type;
|
|
70
|
-
// Handle by GraphQL type first (this is what the error messages reference)
|
|
71
|
-
if (gqlType === 'GeometryPoint') {
|
|
72
|
-
return geometryPointAst(name);
|
|
73
|
-
}
|
|
74
|
-
if (gqlType === 'Interval') {
|
|
75
|
-
return intervalAst(name);
|
|
76
|
-
}
|
|
77
|
-
if (gqlType === 'GeometryGeometryCollection') {
|
|
78
|
-
return geometryCollectionAst(name);
|
|
79
|
-
}
|
|
80
|
-
// Handle by pgType as fallback
|
|
81
|
-
if (pgType === 'geometry') {
|
|
82
|
-
return geometryAst(name);
|
|
83
|
-
}
|
|
84
|
-
if (pgType === 'interval') {
|
|
85
|
-
return intervalAst(name);
|
|
86
|
-
}
|
|
87
|
-
// Return simple field for scalar types
|
|
88
|
-
return t.field({
|
|
89
|
-
name,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Check if a CleanField requires subfield selection based on its GraphQL type
|
|
94
|
-
*/
|
|
95
|
-
function requiresSubfieldSelection(field) {
|
|
96
|
-
const { gqlType } = field.type;
|
|
97
|
-
// Complex GraphQL types that require subfield selection
|
|
98
|
-
const complexTypes = [
|
|
99
|
-
'GeometryPoint',
|
|
100
|
-
'Interval',
|
|
101
|
-
'GeometryGeometryCollection',
|
|
102
|
-
'GeoJSON',
|
|
103
|
-
];
|
|
104
|
-
return complexTypes.includes(gqlType);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Generate AST for GeometryPoint type
|
|
108
|
-
*/
|
|
109
|
-
function geometryPointAst(name) {
|
|
110
|
-
return t.field({
|
|
111
|
-
name,
|
|
112
|
-
selectionSet: t.selectionSet({
|
|
113
|
-
selections: toFieldArray(['x', 'y']),
|
|
114
|
-
}),
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Generate AST for GeometryGeometryCollection type
|
|
119
|
-
*/
|
|
120
|
-
function geometryCollectionAst(name) {
|
|
121
|
-
// Manually create inline fragment since gql-ast doesn't support it
|
|
122
|
-
const inlineFragment = {
|
|
123
|
-
kind: graphql_1.Kind.INLINE_FRAGMENT,
|
|
124
|
-
typeCondition: {
|
|
125
|
-
kind: graphql_1.Kind.NAMED_TYPE,
|
|
126
|
-
name: {
|
|
127
|
-
kind: graphql_1.Kind.NAME,
|
|
128
|
-
value: 'GeometryPoint',
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
selectionSet: {
|
|
132
|
-
kind: graphql_1.Kind.SELECTION_SET,
|
|
133
|
-
selections: [
|
|
134
|
-
{
|
|
135
|
-
kind: graphql_1.Kind.FIELD,
|
|
136
|
-
name: {
|
|
137
|
-
kind: graphql_1.Kind.NAME,
|
|
138
|
-
value: 'x',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
kind: graphql_1.Kind.FIELD,
|
|
143
|
-
name: {
|
|
144
|
-
kind: graphql_1.Kind.NAME,
|
|
145
|
-
value: 'y',
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
],
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
return t.field({
|
|
152
|
-
name,
|
|
153
|
-
selectionSet: t.selectionSet({
|
|
154
|
-
selections: [
|
|
155
|
-
t.field({
|
|
156
|
-
name: 'geometries',
|
|
157
|
-
selectionSet: t.selectionSet({
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
|
-
selections: [inlineFragment], // gql-ast limitation with inline fragments
|
|
160
|
-
}),
|
|
161
|
-
}),
|
|
162
|
-
],
|
|
163
|
-
}),
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Generate AST for generic geometry type (returns geojson)
|
|
168
|
-
*/
|
|
169
|
-
function geometryAst(name) {
|
|
170
|
-
return t.field({
|
|
171
|
-
name,
|
|
172
|
-
selectionSet: t.selectionSet({
|
|
173
|
-
selections: toFieldArray(['geojson']),
|
|
174
|
-
}),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Generate AST for interval type
|
|
179
|
-
*/
|
|
180
|
-
function intervalAst(name) {
|
|
181
|
-
return t.field({
|
|
182
|
-
name,
|
|
183
|
-
selectionSet: t.selectionSet({
|
|
184
|
-
selections: toFieldArray([
|
|
185
|
-
'days',
|
|
186
|
-
'hours',
|
|
187
|
-
'minutes',
|
|
188
|
-
'months',
|
|
189
|
-
'seconds',
|
|
190
|
-
'years',
|
|
191
|
-
]),
|
|
192
|
-
}),
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function toFieldArray(strArr) {
|
|
196
|
-
return strArr.map((fieldName) => t.field({ name: fieldName }));
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Check if an object has interval type shape
|
|
200
|
-
*/
|
|
201
|
-
function isIntervalType(obj) {
|
|
202
|
-
if (!obj || typeof obj !== 'object')
|
|
203
|
-
return false;
|
|
204
|
-
return ['days', 'hours', 'minutes', 'months', 'seconds', 'years'].every((key) => Object.prototype.hasOwnProperty.call(obj, key));
|
|
205
|
-
}
|
|
3
|
+
exports.isIntervalType = exports.intervalAst = exports.geometryAst = exports.geometryCollectionAst = exports.geometryPointAst = exports.requiresSubfieldSelection = exports.getCustomAstForCleanField = exports.getCustomAst = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Re-export custom AST utilities from @constructive-io/graphql-query.
|
|
6
|
+
*
|
|
7
|
+
* These custom AST builders handle PostgreSQL types that need subfield selections
|
|
8
|
+
* (geometry, interval, etc.). The canonical implementations now live in graphql-query.
|
|
9
|
+
*/
|
|
10
|
+
var graphql_query_1 = require("@constructive-io/graphql-query");
|
|
11
|
+
Object.defineProperty(exports, "getCustomAst", { enumerable: true, get: function () { return graphql_query_1.getCustomAst; } });
|
|
12
|
+
Object.defineProperty(exports, "getCustomAstForCleanField", { enumerable: true, get: function () { return graphql_query_1.getCustomAstForCleanField; } });
|
|
13
|
+
Object.defineProperty(exports, "requiresSubfieldSelection", { enumerable: true, get: function () { return graphql_query_1.requiresSubfieldSelection; } });
|
|
14
|
+
Object.defineProperty(exports, "geometryPointAst", { enumerable: true, get: function () { return graphql_query_1.geometryPointAst; } });
|
|
15
|
+
Object.defineProperty(exports, "geometryCollectionAst", { enumerable: true, get: function () { return graphql_query_1.geometryCollectionAst; } });
|
|
16
|
+
Object.defineProperty(exports, "geometryAst", { enumerable: true, get: function () { return graphql_query_1.geometryAst; } });
|
|
17
|
+
Object.defineProperty(exports, "intervalAst", { enumerable: true, get: function () { return graphql_query_1.intervalAst; } });
|
|
18
|
+
Object.defineProperty(exports, "isIntervalType", { enumerable: true, get: function () { return graphql_query_1.isIntervalType; } });
|
|
@@ -1,42 +1,4 @@
|
|
|
1
|
-
import type { IntrospectionQueryResponse } from '../../types/introspection';
|
|
2
|
-
import type { CleanTable } from '../../types/schema';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* Re-export table inference from @constructive-io/graphql-query.
|
|
5
3
|
*/
|
|
6
|
-
|
|
7
|
-
connection: RegExp;
|
|
8
|
-
edge: RegExp;
|
|
9
|
-
filter: RegExp;
|
|
10
|
-
condition: RegExp;
|
|
11
|
-
orderBy: RegExp;
|
|
12
|
-
patch: RegExp;
|
|
13
|
-
createInput: RegExp;
|
|
14
|
-
updateInput: RegExp;
|
|
15
|
-
deleteInput: RegExp;
|
|
16
|
-
createPayload: RegExp;
|
|
17
|
-
updatePayload: RegExp;
|
|
18
|
-
deletePayload: RegExp;
|
|
19
|
-
createMutation: RegExp;
|
|
20
|
-
updateMutation: RegExp;
|
|
21
|
-
deleteMutation: RegExp;
|
|
22
|
-
};
|
|
23
|
-
export interface InferTablesOptions {
|
|
24
|
-
/**
|
|
25
|
-
* Custom pattern overrides (for non-standard PostGraphile configurations)
|
|
26
|
-
*/
|
|
27
|
-
patterns?: Partial<typeof PATTERNS>;
|
|
28
|
-
/**
|
|
29
|
-
* Include PostgreSQL COMMENT descriptions on tables and fields.
|
|
30
|
-
* @default true
|
|
31
|
-
*/
|
|
32
|
-
comments?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Infer CleanTable[] from GraphQL introspection by recognizing PostGraphile patterns
|
|
36
|
-
*
|
|
37
|
-
* @param introspection - Standard GraphQL introspection response
|
|
38
|
-
* @param options - Optional configuration
|
|
39
|
-
* @returns Array of CleanTable objects compatible with existing generators
|
|
40
|
-
*/
|
|
41
|
-
export declare function inferTablesFromIntrospection(introspection: IntrospectionQueryResponse, options?: InferTablesOptions): CleanTable[];
|
|
42
|
-
export {};
|
|
4
|
+
export { inferTablesFromIntrospection, type InferTablesOptions, } from '@constructive-io/graphql-query';
|