@constructive-io/graphql-codegen 2.19.0 → 2.20.1

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 (301) hide show
  1. package/README.md +1818 -113
  2. package/__tests__/codegen/input-types-generator.test.d.ts +1 -0
  3. package/__tests__/codegen/input-types-generator.test.js +635 -0
  4. package/cli/codegen/barrel.d.ts +27 -0
  5. package/cli/codegen/barrel.js +163 -0
  6. package/cli/codegen/client.d.ts +4 -0
  7. package/cli/codegen/client.js +170 -0
  8. package/cli/codegen/custom-mutations.d.ts +38 -0
  9. package/cli/codegen/custom-mutations.js +149 -0
  10. package/cli/codegen/custom-queries.d.ts +38 -0
  11. package/cli/codegen/custom-queries.js +358 -0
  12. package/cli/codegen/filters.d.ts +27 -0
  13. package/cli/codegen/filters.js +357 -0
  14. package/cli/codegen/gql-ast.d.ts +41 -0
  15. package/cli/codegen/gql-ast.js +329 -0
  16. package/cli/codegen/index.d.ts +71 -0
  17. package/cli/codegen/index.js +147 -0
  18. package/cli/codegen/mutations.d.ts +30 -0
  19. package/cli/codegen/mutations.js +410 -0
  20. package/cli/codegen/orm/barrel.d.ts +18 -0
  21. package/cli/codegen/orm/barrel.js +48 -0
  22. package/cli/codegen/orm/client-generator.d.ts +45 -0
  23. package/cli/codegen/orm/client-generator.js +646 -0
  24. package/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
  25. package/cli/codegen/orm/custom-ops-generator.js +350 -0
  26. package/cli/codegen/orm/index.d.ts +38 -0
  27. package/cli/codegen/orm/index.js +88 -0
  28. package/cli/codegen/orm/input-types-generator.d.ts +21 -0
  29. package/cli/codegen/orm/input-types-generator.js +705 -0
  30. package/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
  31. package/cli/codegen/orm/input-types-generator.test.js +75 -0
  32. package/cli/codegen/orm/model-generator.d.ts +32 -0
  33. package/cli/codegen/orm/model-generator.js +264 -0
  34. package/cli/codegen/orm/query-builder.d.ts +161 -0
  35. package/cli/codegen/orm/query-builder.js +366 -0
  36. package/cli/codegen/orm/select-types.d.ts +169 -0
  37. package/cli/codegen/orm/select-types.js +16 -0
  38. package/cli/codegen/orm/select-types.test.d.ts +11 -0
  39. package/cli/codegen/orm/select-types.test.js +22 -0
  40. package/cli/codegen/queries.d.ts +25 -0
  41. package/cli/codegen/queries.js +438 -0
  42. package/cli/codegen/scalars.d.ts +12 -0
  43. package/cli/codegen/scalars.js +71 -0
  44. package/cli/codegen/schema-gql-ast.d.ts +51 -0
  45. package/cli/codegen/schema-gql-ast.js +385 -0
  46. package/cli/codegen/ts-ast.d.ts +122 -0
  47. package/cli/codegen/ts-ast.js +280 -0
  48. package/cli/codegen/type-resolver.d.ts +96 -0
  49. package/cli/codegen/type-resolver.js +246 -0
  50. package/cli/codegen/types.d.ts +12 -0
  51. package/cli/codegen/types.js +69 -0
  52. package/cli/codegen/utils.d.ts +163 -0
  53. package/cli/codegen/utils.js +326 -0
  54. package/cli/commands/generate-orm.d.ts +37 -0
  55. package/cli/commands/generate-orm.js +195 -0
  56. package/cli/commands/generate.d.ts +39 -0
  57. package/cli/commands/generate.js +299 -0
  58. package/cli/commands/index.d.ts +7 -0
  59. package/cli/commands/index.js +12 -0
  60. package/cli/commands/init.d.ts +35 -0
  61. package/cli/commands/init.js +176 -0
  62. package/cli/index.d.ts +4 -0
  63. package/cli/index.js +291 -0
  64. package/cli/introspect/fetch-meta.d.ts +31 -0
  65. package/cli/introspect/fetch-meta.js +108 -0
  66. package/cli/introspect/fetch-schema.d.ts +21 -0
  67. package/cli/introspect/fetch-schema.js +86 -0
  68. package/cli/introspect/index.d.ts +8 -0
  69. package/cli/introspect/index.js +16 -0
  70. package/cli/introspect/meta-query.d.ts +111 -0
  71. package/cli/introspect/meta-query.js +191 -0
  72. package/cli/introspect/schema-query.d.ts +20 -0
  73. package/cli/introspect/schema-query.js +123 -0
  74. package/cli/introspect/transform-schema.d.ts +74 -0
  75. package/cli/introspect/transform-schema.js +269 -0
  76. package/cli/introspect/transform-schema.test.d.ts +1 -0
  77. package/cli/introspect/transform-schema.test.js +67 -0
  78. package/cli/introspect/transform.d.ts +21 -0
  79. package/cli/introspect/transform.js +216 -0
  80. package/cli/watch/cache.d.ts +45 -0
  81. package/cli/watch/cache.js +111 -0
  82. package/cli/watch/debounce.d.ts +19 -0
  83. package/cli/watch/debounce.js +89 -0
  84. package/cli/watch/hash.d.ts +17 -0
  85. package/cli/watch/hash.js +48 -0
  86. package/cli/watch/index.d.ts +10 -0
  87. package/cli/watch/index.js +22 -0
  88. package/cli/watch/orchestrator.d.ts +63 -0
  89. package/cli/watch/orchestrator.js +228 -0
  90. package/cli/watch/poller.d.ts +65 -0
  91. package/cli/watch/poller.js +203 -0
  92. package/cli/watch/types.d.ts +67 -0
  93. package/cli/watch/types.js +5 -0
  94. package/client/error.d.ts +95 -0
  95. package/client/error.js +255 -0
  96. package/client/execute.d.ts +57 -0
  97. package/client/execute.js +124 -0
  98. package/client/index.d.ts +6 -0
  99. package/client/index.js +18 -0
  100. package/client/typed-document.d.ts +31 -0
  101. package/client/typed-document.js +44 -0
  102. package/core/ast.d.ts +10 -0
  103. package/core/ast.js +593 -0
  104. package/core/custom-ast.d.ts +35 -0
  105. package/core/custom-ast.js +204 -0
  106. package/core/index.d.ts +8 -0
  107. package/core/index.js +33 -0
  108. package/core/meta-object/convert.d.ts +65 -0
  109. package/core/meta-object/convert.js +63 -0
  110. package/core/meta-object/format.json +93 -0
  111. package/core/meta-object/index.d.ts +2 -0
  112. package/core/meta-object/index.js +18 -0
  113. package/core/meta-object/validate.d.ts +9 -0
  114. package/core/meta-object/validate.js +34 -0
  115. package/core/query-builder.d.ts +46 -0
  116. package/core/query-builder.js +412 -0
  117. package/core/types.d.ts +139 -0
  118. package/core/types.js +28 -0
  119. package/esm/__tests__/codegen/input-types-generator.test.d.ts +1 -0
  120. package/esm/__tests__/codegen/input-types-generator.test.js +633 -0
  121. package/esm/cli/codegen/barrel.d.ts +27 -0
  122. package/esm/cli/codegen/barrel.js +156 -0
  123. package/esm/cli/codegen/client.d.ts +4 -0
  124. package/esm/cli/codegen/client.js +167 -0
  125. package/esm/cli/codegen/custom-mutations.d.ts +38 -0
  126. package/esm/cli/codegen/custom-mutations.js +145 -0
  127. package/esm/cli/codegen/custom-queries.d.ts +38 -0
  128. package/esm/cli/codegen/custom-queries.js +354 -0
  129. package/esm/cli/codegen/filters.d.ts +27 -0
  130. package/esm/cli/codegen/filters.js +351 -0
  131. package/esm/cli/codegen/gql-ast.d.ts +41 -0
  132. package/esm/cli/codegen/gql-ast.js +288 -0
  133. package/esm/cli/codegen/index.d.ts +71 -0
  134. package/esm/cli/codegen/index.js +124 -0
  135. package/esm/cli/codegen/mutations.d.ts +30 -0
  136. package/esm/cli/codegen/mutations.js +404 -0
  137. package/esm/cli/codegen/orm/barrel.d.ts +18 -0
  138. package/esm/cli/codegen/orm/barrel.js +44 -0
  139. package/esm/cli/codegen/orm/client-generator.d.ts +45 -0
  140. package/esm/cli/codegen/orm/client-generator.js +640 -0
  141. package/esm/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
  142. package/esm/cli/codegen/orm/custom-ops-generator.js +346 -0
  143. package/esm/cli/codegen/orm/index.d.ts +38 -0
  144. package/esm/cli/codegen/orm/index.js +75 -0
  145. package/esm/cli/codegen/orm/input-types-generator.d.ts +21 -0
  146. package/esm/cli/codegen/orm/input-types-generator.js +700 -0
  147. package/esm/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
  148. package/esm/cli/codegen/orm/input-types-generator.test.js +73 -0
  149. package/esm/cli/codegen/orm/model-generator.d.ts +32 -0
  150. package/esm/cli/codegen/orm/model-generator.js +260 -0
  151. package/esm/cli/codegen/orm/query-builder.d.ts +161 -0
  152. package/esm/cli/codegen/orm/query-builder.js +353 -0
  153. package/esm/cli/codegen/orm/select-types.d.ts +169 -0
  154. package/esm/cli/codegen/orm/select-types.js +15 -0
  155. package/esm/cli/codegen/orm/select-types.test.d.ts +11 -0
  156. package/esm/cli/codegen/orm/select-types.test.js +21 -0
  157. package/esm/cli/codegen/queries.d.ts +25 -0
  158. package/esm/cli/codegen/queries.js +433 -0
  159. package/esm/cli/codegen/scalars.d.ts +12 -0
  160. package/esm/cli/codegen/scalars.js +66 -0
  161. package/esm/cli/codegen/schema-gql-ast.d.ts +51 -0
  162. package/esm/cli/codegen/schema-gql-ast.js +343 -0
  163. package/esm/cli/codegen/ts-ast.d.ts +122 -0
  164. package/esm/cli/codegen/ts-ast.js +260 -0
  165. package/esm/cli/codegen/type-resolver.d.ts +96 -0
  166. package/esm/cli/codegen/type-resolver.js +224 -0
  167. package/esm/cli/codegen/types.d.ts +12 -0
  168. package/esm/cli/codegen/types.js +65 -0
  169. package/esm/cli/codegen/utils.d.ts +163 -0
  170. package/esm/cli/codegen/utils.js +288 -0
  171. package/esm/cli/commands/generate-orm.d.ts +37 -0
  172. package/esm/cli/commands/generate-orm.js +192 -0
  173. package/esm/cli/commands/generate.d.ts +39 -0
  174. package/esm/cli/commands/generate.js +262 -0
  175. package/esm/cli/commands/index.d.ts +7 -0
  176. package/esm/cli/commands/index.js +5 -0
  177. package/esm/cli/commands/init.d.ts +35 -0
  178. package/esm/cli/commands/init.js +138 -0
  179. package/esm/cli/index.d.ts +4 -0
  180. package/esm/cli/index.js +256 -0
  181. package/esm/cli/introspect/fetch-meta.d.ts +31 -0
  182. package/esm/cli/introspect/fetch-meta.js +104 -0
  183. package/esm/cli/introspect/fetch-schema.d.ts +21 -0
  184. package/esm/cli/introspect/fetch-schema.js +83 -0
  185. package/esm/cli/introspect/index.d.ts +8 -0
  186. package/esm/cli/introspect/index.js +6 -0
  187. package/esm/cli/introspect/meta-query.d.ts +111 -0
  188. package/esm/cli/introspect/meta-query.js +188 -0
  189. package/esm/cli/introspect/schema-query.d.ts +20 -0
  190. package/esm/cli/introspect/schema-query.js +120 -0
  191. package/esm/cli/introspect/transform-schema.d.ts +74 -0
  192. package/esm/cli/introspect/transform-schema.js +259 -0
  193. package/esm/cli/introspect/transform-schema.test.d.ts +1 -0
  194. package/esm/cli/introspect/transform-schema.test.js +65 -0
  195. package/esm/cli/introspect/transform.d.ts +21 -0
  196. package/esm/cli/introspect/transform.js +210 -0
  197. package/esm/cli/watch/cache.d.ts +45 -0
  198. package/esm/cli/watch/cache.js +73 -0
  199. package/esm/cli/watch/debounce.d.ts +19 -0
  200. package/esm/cli/watch/debounce.js +85 -0
  201. package/esm/cli/watch/hash.d.ts +17 -0
  202. package/esm/cli/watch/hash.js +43 -0
  203. package/esm/cli/watch/index.d.ts +10 -0
  204. package/esm/cli/watch/index.js +8 -0
  205. package/esm/cli/watch/orchestrator.d.ts +63 -0
  206. package/esm/cli/watch/orchestrator.js +223 -0
  207. package/esm/cli/watch/poller.d.ts +65 -0
  208. package/esm/cli/watch/poller.js +198 -0
  209. package/esm/cli/watch/types.d.ts +67 -0
  210. package/esm/cli/watch/types.js +4 -0
  211. package/esm/client/error.d.ts +95 -0
  212. package/esm/client/error.js +249 -0
  213. package/esm/client/execute.d.ts +57 -0
  214. package/esm/client/execute.js +120 -0
  215. package/esm/client/index.d.ts +6 -0
  216. package/esm/client/index.js +6 -0
  217. package/esm/client/typed-document.d.ts +31 -0
  218. package/esm/client/typed-document.js +40 -0
  219. package/esm/core/ast.d.ts +10 -0
  220. package/esm/core/ast.js +549 -0
  221. package/esm/core/custom-ast.d.ts +35 -0
  222. package/esm/core/custom-ast.js +161 -0
  223. package/esm/core/index.d.ts +8 -0
  224. package/esm/core/index.js +12 -0
  225. package/esm/core/meta-object/convert.d.ts +65 -0
  226. package/esm/core/meta-object/convert.js +60 -0
  227. package/esm/core/meta-object/format.json +93 -0
  228. package/esm/core/meta-object/index.d.ts +2 -0
  229. package/esm/core/meta-object/index.js +2 -0
  230. package/esm/core/meta-object/validate.d.ts +9 -0
  231. package/esm/core/meta-object/validate.js +28 -0
  232. package/esm/core/query-builder.d.ts +46 -0
  233. package/esm/core/query-builder.js +375 -0
  234. package/esm/core/types.d.ts +139 -0
  235. package/esm/core/types.js +24 -0
  236. package/esm/generators/field-selector.d.ts +30 -0
  237. package/esm/generators/field-selector.js +355 -0
  238. package/esm/generators/index.d.ts +6 -0
  239. package/esm/generators/index.js +9 -0
  240. package/esm/generators/mutations.d.ts +31 -0
  241. package/esm/generators/mutations.js +197 -0
  242. package/esm/generators/select.d.ts +50 -0
  243. package/esm/generators/select.js +636 -0
  244. package/esm/index.d.ts +12 -0
  245. package/esm/index.js +17 -3
  246. package/esm/react/index.d.ts +5 -0
  247. package/esm/react/index.js +6 -0
  248. package/esm/types/config.d.ts +199 -0
  249. package/esm/types/config.js +106 -0
  250. package/esm/types/index.d.ts +9 -0
  251. package/esm/types/index.js +4 -0
  252. package/esm/types/introspection.d.ts +121 -0
  253. package/esm/types/introspection.js +54 -0
  254. package/esm/types/mutation.d.ts +45 -0
  255. package/esm/types/mutation.js +4 -0
  256. package/esm/types/query.d.ts +82 -0
  257. package/esm/types/query.js +4 -0
  258. package/esm/types/schema.d.ts +253 -0
  259. package/esm/types/schema.js +5 -0
  260. package/esm/types/selection.d.ts +43 -0
  261. package/esm/types/selection.js +4 -0
  262. package/esm/utils/index.d.ts +4 -0
  263. package/esm/utils/index.js +4 -0
  264. package/generators/field-selector.d.ts +30 -0
  265. package/generators/field-selector.js +361 -0
  266. package/generators/index.d.ts +6 -0
  267. package/generators/index.js +27 -0
  268. package/generators/mutations.d.ts +31 -0
  269. package/generators/mutations.js +235 -0
  270. package/generators/select.d.ts +50 -0
  271. package/generators/select.js +679 -0
  272. package/index.d.ts +12 -3
  273. package/index.js +19 -3
  274. package/package.json +59 -38
  275. package/react/index.d.ts +5 -0
  276. package/react/index.js +9 -0
  277. package/types/config.d.ts +199 -0
  278. package/types/config.js +111 -0
  279. package/types/index.d.ts +9 -0
  280. package/types/index.js +10 -0
  281. package/types/introspection.d.ts +121 -0
  282. package/types/introspection.js +62 -0
  283. package/types/mutation.d.ts +45 -0
  284. package/types/mutation.js +5 -0
  285. package/types/query.d.ts +82 -0
  286. package/types/query.js +5 -0
  287. package/types/schema.d.ts +253 -0
  288. package/types/schema.js +6 -0
  289. package/types/selection.d.ts +43 -0
  290. package/types/selection.js +5 -0
  291. package/utils/index.d.ts +4 -0
  292. package/utils/index.js +7 -0
  293. package/codegen.d.ts +0 -13
  294. package/codegen.js +0 -293
  295. package/esm/codegen.js +0 -253
  296. package/esm/gql.js +0 -939
  297. package/esm/options.js +0 -27
  298. package/gql.d.ts +0 -188
  299. package/gql.js +0 -992
  300. package/options.d.ts +0 -45
  301. package/options.js +0 -31
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchSchema = fetchSchema;
4
+ /**
5
+ * Fetch GraphQL schema introspection from an endpoint
6
+ */
7
+ const schema_query_1 = require("./schema-query");
8
+ /**
9
+ * Fetch the full schema introspection from a GraphQL endpoint
10
+ */
11
+ async function fetchSchema(options) {
12
+ const { endpoint, authorization, headers = {}, timeout = 30000 } = options;
13
+ // Build headers
14
+ const requestHeaders = {
15
+ 'Content-Type': 'application/json',
16
+ Accept: 'application/json',
17
+ ...headers,
18
+ };
19
+ if (authorization) {
20
+ requestHeaders['Authorization'] = authorization;
21
+ }
22
+ // Create abort controller for timeout
23
+ const controller = new AbortController();
24
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
25
+ try {
26
+ const response = await fetch(endpoint, {
27
+ method: 'POST',
28
+ headers: requestHeaders,
29
+ body: JSON.stringify({
30
+ query: schema_query_1.SCHEMA_INTROSPECTION_QUERY,
31
+ variables: {},
32
+ }),
33
+ signal: controller.signal,
34
+ });
35
+ clearTimeout(timeoutId);
36
+ if (!response.ok) {
37
+ return {
38
+ success: false,
39
+ error: `HTTP ${response.status}: ${response.statusText}`,
40
+ statusCode: response.status,
41
+ };
42
+ }
43
+ const json = (await response.json());
44
+ // Check for GraphQL errors
45
+ if (json.errors && json.errors.length > 0) {
46
+ const errorMessages = json.errors.map((e) => e.message).join('; ');
47
+ return {
48
+ success: false,
49
+ error: `GraphQL errors: ${errorMessages}`,
50
+ statusCode: response.status,
51
+ };
52
+ }
53
+ // Check if __schema is present
54
+ if (!json.data?.__schema) {
55
+ return {
56
+ success: false,
57
+ error: 'No __schema field in response. Introspection may be disabled on this endpoint.',
58
+ statusCode: response.status,
59
+ };
60
+ }
61
+ return {
62
+ success: true,
63
+ data: json.data,
64
+ statusCode: response.status,
65
+ };
66
+ }
67
+ catch (err) {
68
+ clearTimeout(timeoutId);
69
+ if (err instanceof Error) {
70
+ if (err.name === 'AbortError') {
71
+ return {
72
+ success: false,
73
+ error: `Request timeout after ${timeout}ms`,
74
+ };
75
+ }
76
+ return {
77
+ success: false,
78
+ error: err.message,
79
+ };
80
+ }
81
+ return {
82
+ success: false,
83
+ error: 'Unknown error occurred',
84
+ };
85
+ }
86
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Introspection module exports
3
+ */
4
+ export { META_QUERY } from './meta-query';
5
+ export type { MetaQueryResponse, MetaTable, MetaField, MetaFieldType, MetaConstraint, MetaForeignKeyConstraint, MetaTableQuery, MetaTableInflection, MetaBelongsToRelation, MetaHasRelation, MetaManyToManyRelation, MetaTableRelations, } from './meta-query';
6
+ export { fetchMeta, validateEndpoint } from './fetch-meta';
7
+ export type { FetchMetaOptions, FetchMetaResult } from './fetch-meta';
8
+ export { transformMetaToCleanTables, getTableNames, findTable, filterTables, } from './transform';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Introspection module exports
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.filterTables = exports.findTable = exports.getTableNames = exports.transformMetaToCleanTables = exports.validateEndpoint = exports.fetchMeta = exports.META_QUERY = void 0;
7
+ var meta_query_1 = require("./meta-query");
8
+ Object.defineProperty(exports, "META_QUERY", { enumerable: true, get: function () { return meta_query_1.META_QUERY; } });
9
+ var fetch_meta_1 = require("./fetch-meta");
10
+ Object.defineProperty(exports, "fetchMeta", { enumerable: true, get: function () { return fetch_meta_1.fetchMeta; } });
11
+ Object.defineProperty(exports, "validateEndpoint", { enumerable: true, get: function () { return fetch_meta_1.validateEndpoint; } });
12
+ var transform_1 = require("./transform");
13
+ Object.defineProperty(exports, "transformMetaToCleanTables", { enumerable: true, get: function () { return transform_1.transformMetaToCleanTables; } });
14
+ Object.defineProperty(exports, "getTableNames", { enumerable: true, get: function () { return transform_1.getTableNames; } });
15
+ Object.defineProperty(exports, "findTable", { enumerable: true, get: function () { return transform_1.findTable; } });
16
+ Object.defineProperty(exports, "filterTables", { enumerable: true, get: function () { return transform_1.filterTables; } });
@@ -0,0 +1,111 @@
1
+ /**
2
+ * The _meta GraphQL query for introspecting PostGraphile schema
3
+ * This query fetches all table metadata including fields, constraints, and relations
4
+ */
5
+ export declare const META_QUERY = "\nquery Meta {\n _meta {\n tables {\n name\n query {\n all\n create\n delete\n one\n update\n }\n fields {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n inflection {\n allRows\n allRowsSimple\n conditionType\n connection\n createField\n createInputType\n createPayloadType\n deleteByPrimaryKey\n deletePayloadType\n edge\n edgeField\n enumType\n filterType\n inputType\n orderByType\n patchField\n patchType\n tableFieldName\n tableType\n typeName\n updateByPrimaryKey\n updatePayloadType\n }\n primaryKeyConstraints {\n name\n fields {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n }\n uniqueConstraints {\n name\n fields {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n }\n foreignKeyConstraints {\n name\n fields {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n refFields {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n refTable {\n name\n }\n }\n relations {\n belongsTo {\n fieldName\n isUnique\n keys {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n references {\n name\n }\n type\n }\n hasOne {\n fieldName\n isUnique\n keys {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n referencedBy {\n name\n }\n type\n }\n hasMany {\n fieldName\n isUnique\n keys {\n name\n type {\n gqlType\n isArray\n modifier\n pgAlias\n pgType\n subtype\n typmod\n }\n }\n referencedBy {\n name\n }\n type\n }\n manyToMany {\n fieldName\n junctionTable {\n name\n }\n rightTable {\n name\n }\n type\n }\n }\n }\n }\n}\n";
6
+ /**
7
+ * Types for the _meta query response
8
+ */
9
+ export interface MetaFieldType {
10
+ gqlType: string;
11
+ isArray: boolean;
12
+ modifier: string | number | null;
13
+ pgAlias: string | null;
14
+ pgType: string | null;
15
+ subtype: string | null;
16
+ typmod: number | null;
17
+ }
18
+ export interface MetaField {
19
+ name: string;
20
+ type: MetaFieldType;
21
+ }
22
+ export interface MetaConstraint {
23
+ name: string;
24
+ fields: MetaField[];
25
+ }
26
+ export interface MetaForeignKeyConstraint extends MetaConstraint {
27
+ refFields: MetaField[];
28
+ refTable: {
29
+ name: string;
30
+ };
31
+ }
32
+ export interface MetaTableQuery {
33
+ all: string;
34
+ create: string;
35
+ delete: string | null;
36
+ one: string;
37
+ update: string | null;
38
+ }
39
+ export interface MetaTableInflection {
40
+ allRows: string;
41
+ allRowsSimple: string;
42
+ conditionType: string;
43
+ connection: string;
44
+ createField: string;
45
+ createInputType: string;
46
+ createPayloadType: string;
47
+ deleteByPrimaryKey: string | null;
48
+ deletePayloadType: string;
49
+ edge: string;
50
+ edgeField: string;
51
+ enumType: string;
52
+ filterType: string | null;
53
+ inputType: string;
54
+ orderByType: string;
55
+ patchField: string;
56
+ patchType: string | null;
57
+ tableFieldName: string;
58
+ tableType: string;
59
+ typeName: string;
60
+ updateByPrimaryKey: string | null;
61
+ updatePayloadType: string | null;
62
+ }
63
+ export interface MetaBelongsToRelation {
64
+ fieldName: string | null;
65
+ isUnique: boolean;
66
+ keys: MetaField[];
67
+ references: {
68
+ name: string;
69
+ };
70
+ type: string | null;
71
+ }
72
+ export interface MetaHasRelation {
73
+ fieldName: string | null;
74
+ isUnique: boolean;
75
+ keys: MetaField[];
76
+ referencedBy: {
77
+ name: string;
78
+ };
79
+ type: string | null;
80
+ }
81
+ export interface MetaManyToManyRelation {
82
+ fieldName: string | null;
83
+ junctionTable: {
84
+ name: string;
85
+ };
86
+ rightTable: {
87
+ name: string;
88
+ };
89
+ type: string | null;
90
+ }
91
+ export interface MetaTableRelations {
92
+ belongsTo: MetaBelongsToRelation[];
93
+ hasOne: MetaHasRelation[];
94
+ hasMany: MetaHasRelation[];
95
+ manyToMany: MetaManyToManyRelation[];
96
+ }
97
+ export interface MetaTable {
98
+ name: string;
99
+ query: MetaTableQuery;
100
+ fields: MetaField[];
101
+ inflection: MetaTableInflection;
102
+ primaryKeyConstraints: MetaConstraint[];
103
+ uniqueConstraints: MetaConstraint[];
104
+ foreignKeyConstraints: MetaForeignKeyConstraint[];
105
+ relations: MetaTableRelations;
106
+ }
107
+ export interface MetaQueryResponse {
108
+ _meta: {
109
+ tables: MetaTable[];
110
+ };
111
+ }
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ /**
3
+ * The _meta GraphQL query for introspecting PostGraphile schema
4
+ * This query fetches all table metadata including fields, constraints, and relations
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.META_QUERY = void 0;
8
+ exports.META_QUERY = `
9
+ query Meta {
10
+ _meta {
11
+ tables {
12
+ name
13
+ query {
14
+ all
15
+ create
16
+ delete
17
+ one
18
+ update
19
+ }
20
+ fields {
21
+ name
22
+ type {
23
+ gqlType
24
+ isArray
25
+ modifier
26
+ pgAlias
27
+ pgType
28
+ subtype
29
+ typmod
30
+ }
31
+ }
32
+ inflection {
33
+ allRows
34
+ allRowsSimple
35
+ conditionType
36
+ connection
37
+ createField
38
+ createInputType
39
+ createPayloadType
40
+ deleteByPrimaryKey
41
+ deletePayloadType
42
+ edge
43
+ edgeField
44
+ enumType
45
+ filterType
46
+ inputType
47
+ orderByType
48
+ patchField
49
+ patchType
50
+ tableFieldName
51
+ tableType
52
+ typeName
53
+ updateByPrimaryKey
54
+ updatePayloadType
55
+ }
56
+ primaryKeyConstraints {
57
+ name
58
+ fields {
59
+ name
60
+ type {
61
+ gqlType
62
+ isArray
63
+ modifier
64
+ pgAlias
65
+ pgType
66
+ subtype
67
+ typmod
68
+ }
69
+ }
70
+ }
71
+ uniqueConstraints {
72
+ name
73
+ fields {
74
+ name
75
+ type {
76
+ gqlType
77
+ isArray
78
+ modifier
79
+ pgAlias
80
+ pgType
81
+ subtype
82
+ typmod
83
+ }
84
+ }
85
+ }
86
+ foreignKeyConstraints {
87
+ name
88
+ fields {
89
+ name
90
+ type {
91
+ gqlType
92
+ isArray
93
+ modifier
94
+ pgAlias
95
+ pgType
96
+ subtype
97
+ typmod
98
+ }
99
+ }
100
+ refFields {
101
+ name
102
+ type {
103
+ gqlType
104
+ isArray
105
+ modifier
106
+ pgAlias
107
+ pgType
108
+ subtype
109
+ typmod
110
+ }
111
+ }
112
+ refTable {
113
+ name
114
+ }
115
+ }
116
+ relations {
117
+ belongsTo {
118
+ fieldName
119
+ isUnique
120
+ keys {
121
+ name
122
+ type {
123
+ gqlType
124
+ isArray
125
+ modifier
126
+ pgAlias
127
+ pgType
128
+ subtype
129
+ typmod
130
+ }
131
+ }
132
+ references {
133
+ name
134
+ }
135
+ type
136
+ }
137
+ hasOne {
138
+ fieldName
139
+ isUnique
140
+ keys {
141
+ name
142
+ type {
143
+ gqlType
144
+ isArray
145
+ modifier
146
+ pgAlias
147
+ pgType
148
+ subtype
149
+ typmod
150
+ }
151
+ }
152
+ referencedBy {
153
+ name
154
+ }
155
+ type
156
+ }
157
+ hasMany {
158
+ fieldName
159
+ isUnique
160
+ keys {
161
+ name
162
+ type {
163
+ gqlType
164
+ isArray
165
+ modifier
166
+ pgAlias
167
+ pgType
168
+ subtype
169
+ typmod
170
+ }
171
+ }
172
+ referencedBy {
173
+ name
174
+ }
175
+ type
176
+ }
177
+ manyToMany {
178
+ fieldName
179
+ junctionTable {
180
+ name
181
+ }
182
+ rightTable {
183
+ name
184
+ }
185
+ type
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
191
+ `;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * GraphQL Schema Introspection Query
3
+ *
4
+ * Full introspection query that captures all queries, mutations, and types
5
+ * from a GraphQL endpoint via the standard __schema query.
6
+ */
7
+ import type { IntrospectionQueryResponse } from '../../types/introspection';
8
+ /**
9
+ * Full schema introspection query
10
+ *
11
+ * Captures:
12
+ * - All Query fields with args and return types
13
+ * - All Mutation fields with args and return types
14
+ * - All types (OBJECT, INPUT_OBJECT, ENUM, SCALAR) for resolution
15
+ *
16
+ * Uses a recursive TypeRef fragment to handle deeply nested type wrappers
17
+ * (e.g., [String!]! = NON_NULL(LIST(NON_NULL(SCALAR))))
18
+ */
19
+ export declare const SCHEMA_INTROSPECTION_QUERY = "\nquery IntrospectSchema {\n __schema {\n queryType {\n name\n }\n mutationType {\n name\n }\n subscriptionType {\n name\n }\n types {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n interfaces {\n name\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n name\n }\n }\n directives {\n name\n description\n locations\n args {\n name\n description\n type {\n ...TypeRef\n }\n defaultValue\n }\n }\n }\n}\n\nfragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n}\n";
20
+ export type { IntrospectionQueryResponse };
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ /**
3
+ * GraphQL Schema Introspection Query
4
+ *
5
+ * Full introspection query that captures all queries, mutations, and types
6
+ * from a GraphQL endpoint via the standard __schema query.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SCHEMA_INTROSPECTION_QUERY = void 0;
10
+ /**
11
+ * Full schema introspection query
12
+ *
13
+ * Captures:
14
+ * - All Query fields with args and return types
15
+ * - All Mutation fields with args and return types
16
+ * - All types (OBJECT, INPUT_OBJECT, ENUM, SCALAR) for resolution
17
+ *
18
+ * Uses a recursive TypeRef fragment to handle deeply nested type wrappers
19
+ * (e.g., [String!]! = NON_NULL(LIST(NON_NULL(SCALAR))))
20
+ */
21
+ exports.SCHEMA_INTROSPECTION_QUERY = `
22
+ query IntrospectSchema {
23
+ __schema {
24
+ queryType {
25
+ name
26
+ }
27
+ mutationType {
28
+ name
29
+ }
30
+ subscriptionType {
31
+ name
32
+ }
33
+ types {
34
+ kind
35
+ name
36
+ description
37
+ fields(includeDeprecated: true) {
38
+ name
39
+ description
40
+ args {
41
+ name
42
+ description
43
+ type {
44
+ ...TypeRef
45
+ }
46
+ defaultValue
47
+ }
48
+ type {
49
+ ...TypeRef
50
+ }
51
+ isDeprecated
52
+ deprecationReason
53
+ }
54
+ inputFields {
55
+ name
56
+ description
57
+ type {
58
+ ...TypeRef
59
+ }
60
+ defaultValue
61
+ }
62
+ interfaces {
63
+ name
64
+ }
65
+ enumValues(includeDeprecated: true) {
66
+ name
67
+ description
68
+ isDeprecated
69
+ deprecationReason
70
+ }
71
+ possibleTypes {
72
+ name
73
+ }
74
+ }
75
+ directives {
76
+ name
77
+ description
78
+ locations
79
+ args {
80
+ name
81
+ description
82
+ type {
83
+ ...TypeRef
84
+ }
85
+ defaultValue
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ fragment TypeRef on __Type {
92
+ kind
93
+ name
94
+ ofType {
95
+ kind
96
+ name
97
+ ofType {
98
+ kind
99
+ name
100
+ ofType {
101
+ kind
102
+ name
103
+ ofType {
104
+ kind
105
+ name
106
+ ofType {
107
+ kind
108
+ name
109
+ ofType {
110
+ kind
111
+ name
112
+ ofType {
113
+ kind
114
+ name
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ `;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Transform GraphQL introspection data to clean operation types
3
+ *
4
+ * This module converts raw introspection responses into the CleanOperation
5
+ * format used by code generators.
6
+ */
7
+ import type { IntrospectionQueryResponse, IntrospectionType } from '../../types/introspection';
8
+ import { unwrapType, getBaseTypeName, isNonNull } from '../../types/introspection';
9
+ import type { CleanOperation, TypeRegistry } from '../../types/schema';
10
+ /**
11
+ * Build a type registry from introspection types
12
+ * Maps type names to their full resolved definitions
13
+ *
14
+ * This is a two-pass process to handle circular references:
15
+ * 1. First pass: Create all type entries with basic info
16
+ * 2. Second pass: Resolve fields with references to other types
17
+ */
18
+ export declare function buildTypeRegistry(types: IntrospectionType[]): TypeRegistry;
19
+ export interface TransformSchemaResult {
20
+ queries: CleanOperation[];
21
+ mutations: CleanOperation[];
22
+ typeRegistry: TypeRegistry;
23
+ }
24
+ /**
25
+ * Transform introspection response to clean operations
26
+ */
27
+ export declare function transformSchemaToOperations(response: IntrospectionQueryResponse): TransformSchemaResult;
28
+ /**
29
+ * Filter operations by include/exclude patterns
30
+ * Uses glob-like patterns (supports * wildcard)
31
+ */
32
+ export declare function filterOperations(operations: CleanOperation[], include?: string[], exclude?: string[]): CleanOperation[];
33
+ /**
34
+ * Get the set of table-related operation names from tables
35
+ * Used to identify which operations are already covered by table generators
36
+ *
37
+ * This includes:
38
+ * - Basic CRUD: all, one, create, update, delete
39
+ * - PostGraphile alternate mutations: updateXByY, deleteXByY (for unique constraints)
40
+ */
41
+ export declare function getTableOperationNames(tables: Array<{
42
+ name: string;
43
+ query?: {
44
+ all: string;
45
+ one: string;
46
+ create: string;
47
+ update: string | null;
48
+ delete: string | null;
49
+ };
50
+ inflection?: {
51
+ tableType: string;
52
+ };
53
+ }>): {
54
+ queries: Set<string>;
55
+ mutations: Set<string>;
56
+ tableTypePatterns: RegExp[];
57
+ };
58
+ /**
59
+ * Check if an operation is a table operation (already handled by table generators)
60
+ */
61
+ export declare function isTableOperation(operation: CleanOperation, tableOperationNames: {
62
+ queries: Set<string>;
63
+ mutations: Set<string>;
64
+ tableTypePatterns: RegExp[];
65
+ }): boolean;
66
+ /**
67
+ * Get only custom operations (not covered by table generators)
68
+ */
69
+ export declare function getCustomOperations(operations: CleanOperation[], tableOperationNames: {
70
+ queries: Set<string>;
71
+ mutations: Set<string>;
72
+ tableTypePatterns: RegExp[];
73
+ }): CleanOperation[];
74
+ export { unwrapType, getBaseTypeName, isNonNull };