@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.
Files changed (71) hide show
  1. package/client/error.d.ts +2 -93
  2. package/client/error.js +9 -273
  3. package/client/execute.d.ts +2 -55
  4. package/client/execute.js +5 -120
  5. package/client/typed-document.d.ts +2 -29
  6. package/client/typed-document.js +3 -39
  7. package/core/ast.d.ts +8 -10
  8. package/core/ast.js +17 -592
  9. package/core/custom-ast.d.ts +5 -33
  10. package/core/custom-ast.js +16 -203
  11. package/core/introspect/infer-tables.d.ts +2 -40
  12. package/core/introspect/infer-tables.js +4 -696
  13. package/core/introspect/schema-query.d.ts +3 -18
  14. package/core/introspect/schema-query.js +3 -118
  15. package/core/introspect/transform-schema.d.ts +2 -84
  16. package/core/introspect/transform-schema.js +14 -279
  17. package/core/introspect/transform.d.ts +2 -18
  18. package/core/introspect/transform.js +6 -39
  19. package/core/meta-object/convert.d.ts +2 -63
  20. package/core/meta-object/convert.js +4 -59
  21. package/core/meta-object/validate.d.ts +2 -7
  22. package/core/meta-object/validate.js +4 -30
  23. package/core/query-builder.d.ts +7 -46
  24. package/core/query-builder.js +8 -408
  25. package/core/types.d.ts +9 -139
  26. package/core/types.js +12 -26
  27. package/esm/client/error.d.ts +2 -93
  28. package/esm/client/error.js +2 -269
  29. package/esm/client/execute.d.ts +2 -55
  30. package/esm/client/execute.js +2 -118
  31. package/esm/client/typed-document.d.ts +2 -29
  32. package/esm/client/typed-document.js +2 -38
  33. package/esm/core/ast.d.ts +8 -10
  34. package/esm/core/ast.js +8 -550
  35. package/esm/core/custom-ast.d.ts +5 -33
  36. package/esm/core/custom-ast.js +5 -160
  37. package/esm/core/introspect/infer-tables.d.ts +2 -40
  38. package/esm/core/introspect/infer-tables.js +2 -695
  39. package/esm/core/introspect/schema-query.d.ts +3 -18
  40. package/esm/core/introspect/schema-query.js +2 -118
  41. package/esm/core/introspect/transform-schema.d.ts +2 -84
  42. package/esm/core/introspect/transform-schema.js +2 -269
  43. package/esm/core/introspect/transform.d.ts +2 -18
  44. package/esm/core/introspect/transform.js +2 -36
  45. package/esm/core/meta-object/convert.d.ts +2 -63
  46. package/esm/core/meta-object/convert.js +2 -58
  47. package/esm/core/meta-object/validate.d.ts +2 -7
  48. package/esm/core/meta-object/validate.js +2 -26
  49. package/esm/core/query-builder.d.ts +7 -46
  50. package/esm/core/query-builder.js +5 -373
  51. package/esm/core/types.d.ts +9 -139
  52. package/esm/core/types.js +9 -24
  53. package/esm/generators/field-selector.d.ts +5 -28
  54. package/esm/generators/field-selector.js +5 -379
  55. package/esm/generators/mutations.d.ts +5 -28
  56. package/esm/generators/mutations.js +5 -198
  57. package/esm/generators/naming-helpers.d.ts +3 -45
  58. package/esm/generators/naming-helpers.js +3 -151
  59. package/esm/generators/select.d.ts +6 -37
  60. package/esm/generators/select.js +6 -659
  61. package/generators/field-selector.d.ts +5 -28
  62. package/generators/field-selector.js +12 -385
  63. package/generators/mutations.d.ts +5 -28
  64. package/generators/mutations.js +9 -234
  65. package/generators/naming-helpers.d.ts +3 -45
  66. package/generators/naming-helpers.js +15 -164
  67. package/generators/select.d.ts +6 -37
  68. package/generators/select.js +17 -703
  69. package/package.json +7 -6
  70. package/core/meta-object/format.json +0 -93
  71. package/esm/core/meta-object/format.json +0 -93
@@ -1,162 +1,7 @@
1
- import * as t from 'gql-ast';
2
- import { Kind } from 'graphql';
3
1
  /**
4
- * Get custom AST for MetaField type - handles PostgreSQL types that need subfield selections
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 function getCustomAst(fieldDefn) {
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
- * PostGraphile naming patterns for type detection
2
+ * Re-export table inference from @constructive-io/graphql-query.
5
3
  */
6
- declare const PATTERNS: {
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';