@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/esm/core/custom-ast.js
CHANGED
|
@@ -1,162 +1,7 @@
|
|
|
1
|
-
import * as t from 'gql-ast';
|
|
2
|
-
import { Kind } from 'graphql';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
2
|
+
* Re-export custom AST utilities from @constructive-io/graphql-query.
|
|
3
|
+
*
|
|
4
|
+
* These custom AST builders handle PostgreSQL types that need subfield selections
|
|
5
|
+
* (geometry, interval, etc.). The canonical implementations now live in graphql-query.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
-
if (!fieldDefn) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const { pgType } = fieldDefn.type;
|
|
11
|
-
if (pgType === 'geometry') {
|
|
12
|
-
return geometryAst(fieldDefn.name);
|
|
13
|
-
}
|
|
14
|
-
if (pgType === 'interval') {
|
|
15
|
-
return intervalAst(fieldDefn.name);
|
|
16
|
-
}
|
|
17
|
-
return t.field({
|
|
18
|
-
name: fieldDefn.name,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Generate custom AST for CleanField type - handles GraphQL types that need subfield selections
|
|
23
|
-
*/
|
|
24
|
-
export function getCustomAstForCleanField(field) {
|
|
25
|
-
const { name, type } = field;
|
|
26
|
-
const { gqlType, pgType } = type;
|
|
27
|
-
// Handle by GraphQL type first (this is what the error messages reference)
|
|
28
|
-
if (gqlType === 'GeometryPoint') {
|
|
29
|
-
return geometryPointAst(name);
|
|
30
|
-
}
|
|
31
|
-
if (gqlType === 'Interval') {
|
|
32
|
-
return intervalAst(name);
|
|
33
|
-
}
|
|
34
|
-
if (gqlType === 'GeometryGeometryCollection') {
|
|
35
|
-
return geometryCollectionAst(name);
|
|
36
|
-
}
|
|
37
|
-
// Handle by pgType as fallback
|
|
38
|
-
if (pgType === 'geometry') {
|
|
39
|
-
return geometryAst(name);
|
|
40
|
-
}
|
|
41
|
-
if (pgType === 'interval') {
|
|
42
|
-
return intervalAst(name);
|
|
43
|
-
}
|
|
44
|
-
// Return simple field for scalar types
|
|
45
|
-
return t.field({
|
|
46
|
-
name,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Check if a CleanField requires subfield selection based on its GraphQL type
|
|
51
|
-
*/
|
|
52
|
-
export function requiresSubfieldSelection(field) {
|
|
53
|
-
const { gqlType } = field.type;
|
|
54
|
-
// Complex GraphQL types that require subfield selection
|
|
55
|
-
const complexTypes = [
|
|
56
|
-
'GeometryPoint',
|
|
57
|
-
'Interval',
|
|
58
|
-
'GeometryGeometryCollection',
|
|
59
|
-
'GeoJSON',
|
|
60
|
-
];
|
|
61
|
-
return complexTypes.includes(gqlType);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Generate AST for GeometryPoint type
|
|
65
|
-
*/
|
|
66
|
-
export function geometryPointAst(name) {
|
|
67
|
-
return t.field({
|
|
68
|
-
name,
|
|
69
|
-
selectionSet: t.selectionSet({
|
|
70
|
-
selections: toFieldArray(['x', 'y']),
|
|
71
|
-
}),
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Generate AST for GeometryGeometryCollection type
|
|
76
|
-
*/
|
|
77
|
-
export function geometryCollectionAst(name) {
|
|
78
|
-
// Manually create inline fragment since gql-ast doesn't support it
|
|
79
|
-
const inlineFragment = {
|
|
80
|
-
kind: Kind.INLINE_FRAGMENT,
|
|
81
|
-
typeCondition: {
|
|
82
|
-
kind: Kind.NAMED_TYPE,
|
|
83
|
-
name: {
|
|
84
|
-
kind: Kind.NAME,
|
|
85
|
-
value: 'GeometryPoint',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
selectionSet: {
|
|
89
|
-
kind: Kind.SELECTION_SET,
|
|
90
|
-
selections: [
|
|
91
|
-
{
|
|
92
|
-
kind: Kind.FIELD,
|
|
93
|
-
name: {
|
|
94
|
-
kind: Kind.NAME,
|
|
95
|
-
value: 'x',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
kind: Kind.FIELD,
|
|
100
|
-
name: {
|
|
101
|
-
kind: Kind.NAME,
|
|
102
|
-
value: 'y',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
return t.field({
|
|
109
|
-
name,
|
|
110
|
-
selectionSet: t.selectionSet({
|
|
111
|
-
selections: [
|
|
112
|
-
t.field({
|
|
113
|
-
name: 'geometries',
|
|
114
|
-
selectionSet: t.selectionSet({
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
-
selections: [inlineFragment], // gql-ast limitation with inline fragments
|
|
117
|
-
}),
|
|
118
|
-
}),
|
|
119
|
-
],
|
|
120
|
-
}),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Generate AST for generic geometry type (returns geojson)
|
|
125
|
-
*/
|
|
126
|
-
export function geometryAst(name) {
|
|
127
|
-
return t.field({
|
|
128
|
-
name,
|
|
129
|
-
selectionSet: t.selectionSet({
|
|
130
|
-
selections: toFieldArray(['geojson']),
|
|
131
|
-
}),
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Generate AST for interval type
|
|
136
|
-
*/
|
|
137
|
-
export function intervalAst(name) {
|
|
138
|
-
return t.field({
|
|
139
|
-
name,
|
|
140
|
-
selectionSet: t.selectionSet({
|
|
141
|
-
selections: toFieldArray([
|
|
142
|
-
'days',
|
|
143
|
-
'hours',
|
|
144
|
-
'minutes',
|
|
145
|
-
'months',
|
|
146
|
-
'seconds',
|
|
147
|
-
'years',
|
|
148
|
-
]),
|
|
149
|
-
}),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function toFieldArray(strArr) {
|
|
153
|
-
return strArr.map((fieldName) => t.field({ name: fieldName }));
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Check if an object has interval type shape
|
|
157
|
-
*/
|
|
158
|
-
export function isIntervalType(obj) {
|
|
159
|
-
if (!obj || typeof obj !== 'object')
|
|
160
|
-
return false;
|
|
161
|
-
return ['days', 'hours', 'minutes', 'months', 'seconds', 'years'].every((key) => Object.prototype.hasOwnProperty.call(obj, key));
|
|
162
|
-
}
|
|
7
|
+
export { getCustomAst, getCustomAstForCleanField, requiresSubfieldSelection, geometryPointAst, geometryCollectionAst, geometryAst, intervalAst, isIntervalType, } from '@constructive-io/graphql-query';
|
|
@@ -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';
|