@constructive-io/graphql-codegen 2.32.0 → 3.0.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 (270) hide show
  1. package/README.md +429 -1691
  2. package/cli/index.d.ts +5 -2
  3. package/cli/index.js +98 -581
  4. package/cli/shared.d.ts +35 -0
  5. package/cli/shared.js +106 -0
  6. package/{esm/cli → core}/codegen/barrel.d.ts +1 -1
  7. package/{cli → core}/codegen/barrel.js +1 -4
  8. package/{esm/cli → core}/codegen/index.d.ts +15 -5
  9. package/{cli → core}/codegen/index.js +44 -24
  10. package/{cli → core}/codegen/invalidation.d.ts +2 -2
  11. package/{esm/cli → core}/codegen/mutation-keys.d.ts +2 -2
  12. package/{cli → core}/codegen/orm/client-generator.js +2 -3
  13. package/{esm/cli → core}/codegen/orm/index.d.ts +9 -2
  14. package/{cli → core}/codegen/orm/index.js +3 -2
  15. package/{cli → core}/codegen/query-keys.d.ts +2 -2
  16. package/core/codegen/shared/index.d.ts +39 -0
  17. package/core/codegen/shared/index.js +118 -0
  18. package/core/config/index.d.ts +5 -0
  19. package/core/config/index.js +13 -0
  20. package/core/config/loader.d.ts +18 -0
  21. package/{cli/commands/init.js → core/config/loader.js} +7 -94
  22. package/core/config/resolver.d.ts +46 -0
  23. package/core/config/resolver.js +104 -0
  24. package/core/database/index.d.ts +43 -0
  25. package/core/database/index.js +85 -0
  26. package/core/generate.d.ts +22 -0
  27. package/core/generate.js +192 -0
  28. package/core/index.d.ts +13 -1
  29. package/core/index.js +22 -2
  30. package/{cli → core}/introspect/fetch-schema.js +58 -9
  31. package/core/introspect/source/api-schemas.d.ts +44 -0
  32. package/core/introspect/source/api-schemas.js +122 -0
  33. package/core/introspect/source/database.d.ts +32 -0
  34. package/core/introspect/source/database.js +91 -0
  35. package/core/introspect/source/index.d.ts +112 -0
  36. package/core/introspect/source/index.js +173 -0
  37. package/core/introspect/source/pgpm-module.d.ts +83 -0
  38. package/core/introspect/source/pgpm-module.js +200 -0
  39. package/core/output/index.d.ts +4 -0
  40. package/core/output/index.js +9 -0
  41. package/core/output/writer.d.ts +38 -0
  42. package/core/output/writer.js +156 -0
  43. package/{cli/commands/shared.d.ts → core/pipeline/index.d.ts} +5 -3
  44. package/{cli/commands/shared.js → core/pipeline/index.js} +4 -0
  45. package/{cli → core}/watch/orchestrator.d.ts +25 -3
  46. package/{cli → core}/watch/orchestrator.js +35 -27
  47. package/{cli → core}/watch/types.d.ts +1 -1
  48. package/esm/cli/index.d.ts +5 -2
  49. package/esm/cli/index.js +97 -547
  50. package/esm/cli/shared.d.ts +35 -0
  51. package/esm/cli/shared.js +101 -0
  52. package/{cli → esm/core}/codegen/barrel.d.ts +1 -1
  53. package/esm/{cli → core}/codegen/barrel.js +1 -4
  54. package/{cli → esm/core}/codegen/index.d.ts +15 -5
  55. package/esm/{cli → core}/codegen/index.js +44 -24
  56. package/esm/{cli → core}/codegen/invalidation.d.ts +2 -2
  57. package/{cli → esm/core}/codegen/mutation-keys.d.ts +2 -2
  58. package/esm/{cli → core}/codegen/orm/client-generator.js +2 -3
  59. package/{cli → esm/core}/codegen/orm/index.d.ts +9 -2
  60. package/esm/{cli → core}/codegen/orm/index.js +3 -2
  61. package/esm/{cli → core}/codegen/query-keys.d.ts +2 -2
  62. package/esm/core/codegen/shared/index.d.ts +39 -0
  63. package/esm/core/codegen/shared/index.js +79 -0
  64. package/esm/core/config/index.d.ts +5 -0
  65. package/esm/core/config/index.js +5 -0
  66. package/esm/core/config/loader.d.ts +18 -0
  67. package/esm/core/config/loader.js +71 -0
  68. package/esm/core/config/resolver.d.ts +46 -0
  69. package/esm/core/config/resolver.js +100 -0
  70. package/esm/core/database/index.d.ts +43 -0
  71. package/esm/core/database/index.js +48 -0
  72. package/esm/core/generate.d.ts +22 -0
  73. package/esm/core/generate.js +186 -0
  74. package/esm/core/index.d.ts +13 -1
  75. package/esm/core/index.js +20 -1
  76. package/esm/{cli → core}/introspect/fetch-schema.js +55 -9
  77. package/esm/core/introspect/source/api-schemas.d.ts +44 -0
  78. package/esm/core/introspect/source/api-schemas.js +117 -0
  79. package/esm/core/introspect/source/database.d.ts +32 -0
  80. package/esm/core/introspect/source/database.js +87 -0
  81. package/esm/core/introspect/source/index.d.ts +112 -0
  82. package/esm/core/introspect/source/index.js +154 -0
  83. package/esm/core/introspect/source/pgpm-module.d.ts +83 -0
  84. package/esm/core/introspect/source/pgpm-module.js +194 -0
  85. package/esm/core/output/index.d.ts +4 -0
  86. package/esm/core/output/index.js +4 -0
  87. package/esm/core/output/writer.d.ts +38 -0
  88. package/esm/core/output/writer.js +119 -0
  89. package/esm/{cli/commands/shared.d.ts → core/pipeline/index.d.ts} +5 -3
  90. package/esm/{cli/commands/shared.js → core/pipeline/index.js} +1 -0
  91. package/esm/{cli → core}/watch/orchestrator.d.ts +25 -3
  92. package/esm/{cli → core}/watch/orchestrator.js +35 -27
  93. package/esm/{cli → core}/watch/types.d.ts +1 -1
  94. package/esm/index.d.ts +8 -3
  95. package/esm/index.js +9 -3
  96. package/esm/types/config.d.ts +101 -138
  97. package/esm/types/config.js +8 -35
  98. package/esm/types/index.d.ts +2 -2
  99. package/esm/types/index.js +1 -1
  100. package/index.d.ts +8 -3
  101. package/index.js +18 -8
  102. package/package.json +18 -11
  103. package/types/config.d.ts +101 -138
  104. package/types/config.js +9 -38
  105. package/types/index.d.ts +2 -2
  106. package/types/index.js +3 -3
  107. package/cli/commands/generate-orm.d.ts +0 -53
  108. package/cli/commands/generate-orm.js +0 -292
  109. package/cli/commands/generate.d.ts +0 -66
  110. package/cli/commands/generate.js +0 -431
  111. package/cli/commands/index.d.ts +0 -9
  112. package/cli/commands/index.js +0 -14
  113. package/cli/commands/init.d.ts +0 -35
  114. package/cli/introspect/source/index.d.ts +0 -48
  115. package/cli/introspect/source/index.js +0 -72
  116. package/esm/cli/commands/generate-orm.d.ts +0 -53
  117. package/esm/cli/commands/generate-orm.js +0 -289
  118. package/esm/cli/commands/generate.d.ts +0 -66
  119. package/esm/cli/commands/generate.js +0 -393
  120. package/esm/cli/commands/index.d.ts +0 -9
  121. package/esm/cli/commands/index.js +0 -6
  122. package/esm/cli/commands/init.d.ts +0 -35
  123. package/esm/cli/commands/init.js +0 -158
  124. package/esm/cli/introspect/source/index.d.ts +0 -48
  125. package/esm/cli/introspect/source/index.js +0 -54
  126. /package/{cli → core}/codegen/babel-ast.d.ts +0 -0
  127. /package/{cli → core}/codegen/babel-ast.js +0 -0
  128. /package/{cli → core}/codegen/client.d.ts +0 -0
  129. /package/{cli → core}/codegen/client.js +0 -0
  130. /package/{cli → core}/codegen/custom-mutations.d.ts +0 -0
  131. /package/{cli → core}/codegen/custom-mutations.js +0 -0
  132. /package/{cli → core}/codegen/custom-queries.d.ts +0 -0
  133. /package/{cli → core}/codegen/custom-queries.js +0 -0
  134. /package/{cli → core}/codegen/gql-ast.d.ts +0 -0
  135. /package/{cli → core}/codegen/gql-ast.js +0 -0
  136. /package/{cli → core}/codegen/invalidation.js +0 -0
  137. /package/{cli → core}/codegen/mutation-keys.js +0 -0
  138. /package/{cli → core}/codegen/mutations.d.ts +0 -0
  139. /package/{cli → core}/codegen/mutations.js +0 -0
  140. /package/{cli → core}/codegen/orm/barrel.d.ts +0 -0
  141. /package/{cli → core}/codegen/orm/barrel.js +0 -0
  142. /package/{cli → core}/codegen/orm/client-generator.d.ts +0 -0
  143. /package/{cli → core}/codegen/orm/client.d.ts +0 -0
  144. /package/{cli → core}/codegen/orm/client.js +0 -0
  145. /package/{cli → core}/codegen/orm/custom-ops-generator.d.ts +0 -0
  146. /package/{cli → core}/codegen/orm/custom-ops-generator.js +0 -0
  147. /package/{cli → core}/codegen/orm/input-types-generator.d.ts +0 -0
  148. /package/{cli → core}/codegen/orm/input-types-generator.js +0 -0
  149. /package/{cli → core}/codegen/orm/model-generator.d.ts +0 -0
  150. /package/{cli → core}/codegen/orm/model-generator.js +0 -0
  151. /package/{cli → core}/codegen/orm/query-builder.d.ts +0 -0
  152. /package/{cli → core}/codegen/orm/query-builder.js +0 -0
  153. /package/{cli → core}/codegen/orm/query-builder.ts +0 -0
  154. /package/{cli → core}/codegen/orm/select-types.d.ts +0 -0
  155. /package/{cli → core}/codegen/orm/select-types.js +0 -0
  156. /package/{cli → core}/codegen/queries.d.ts +0 -0
  157. /package/{cli → core}/codegen/queries.js +0 -0
  158. /package/{cli → core}/codegen/query-keys.js +0 -0
  159. /package/{cli → core}/codegen/scalars.d.ts +0 -0
  160. /package/{cli → core}/codegen/scalars.js +0 -0
  161. /package/{cli → core}/codegen/schema-gql-ast.d.ts +0 -0
  162. /package/{cli → core}/codegen/schema-gql-ast.js +0 -0
  163. /package/{cli → core}/codegen/schema-types-generator.d.ts +0 -0
  164. /package/{cli → core}/codegen/schema-types-generator.js +0 -0
  165. /package/{cli → core}/codegen/type-resolver.d.ts +0 -0
  166. /package/{cli → core}/codegen/type-resolver.js +0 -0
  167. /package/{cli → core}/codegen/types.d.ts +0 -0
  168. /package/{cli → core}/codegen/types.js +0 -0
  169. /package/{cli → core}/codegen/utils.d.ts +0 -0
  170. /package/{cli → core}/codegen/utils.js +0 -0
  171. /package/{cli → core}/introspect/fetch-schema.d.ts +0 -0
  172. /package/{cli → core}/introspect/index.d.ts +0 -0
  173. /package/{cli → core}/introspect/index.js +0 -0
  174. /package/{cli → core}/introspect/infer-tables.d.ts +0 -0
  175. /package/{cli → core}/introspect/infer-tables.js +0 -0
  176. /package/{cli → core}/introspect/schema-query.d.ts +0 -0
  177. /package/{cli → core}/introspect/schema-query.js +0 -0
  178. /package/{cli → core}/introspect/source/endpoint.d.ts +0 -0
  179. /package/{cli → core}/introspect/source/endpoint.js +0 -0
  180. /package/{cli → core}/introspect/source/file.d.ts +0 -0
  181. /package/{cli → core}/introspect/source/file.js +0 -0
  182. /package/{cli → core}/introspect/source/types.d.ts +0 -0
  183. /package/{cli → core}/introspect/source/types.js +0 -0
  184. /package/{cli → core}/introspect/transform-schema.d.ts +0 -0
  185. /package/{cli → core}/introspect/transform-schema.js +0 -0
  186. /package/{cli → core}/introspect/transform.d.ts +0 -0
  187. /package/{cli → core}/introspect/transform.js +0 -0
  188. /package/{cli → core}/watch/cache.d.ts +0 -0
  189. /package/{cli → core}/watch/cache.js +0 -0
  190. /package/{cli → core}/watch/debounce.d.ts +0 -0
  191. /package/{cli → core}/watch/debounce.js +0 -0
  192. /package/{cli → core}/watch/hash.d.ts +0 -0
  193. /package/{cli → core}/watch/hash.js +0 -0
  194. /package/{cli → core}/watch/index.d.ts +0 -0
  195. /package/{cli → core}/watch/index.js +0 -0
  196. /package/{cli → core}/watch/poller.d.ts +0 -0
  197. /package/{cli → core}/watch/poller.js +0 -0
  198. /package/{cli → core}/watch/types.js +0 -0
  199. /package/esm/{cli → core}/codegen/babel-ast.d.ts +0 -0
  200. /package/esm/{cli → core}/codegen/babel-ast.js +0 -0
  201. /package/esm/{cli → core}/codegen/client.d.ts +0 -0
  202. /package/esm/{cli → core}/codegen/client.js +0 -0
  203. /package/esm/{cli → core}/codegen/custom-mutations.d.ts +0 -0
  204. /package/esm/{cli → core}/codegen/custom-mutations.js +0 -0
  205. /package/esm/{cli → core}/codegen/custom-queries.d.ts +0 -0
  206. /package/esm/{cli → core}/codegen/custom-queries.js +0 -0
  207. /package/esm/{cli → core}/codegen/gql-ast.d.ts +0 -0
  208. /package/esm/{cli → core}/codegen/gql-ast.js +0 -0
  209. /package/esm/{cli → core}/codegen/invalidation.js +0 -0
  210. /package/esm/{cli → core}/codegen/mutation-keys.js +0 -0
  211. /package/esm/{cli → core}/codegen/mutations.d.ts +0 -0
  212. /package/esm/{cli → core}/codegen/mutations.js +0 -0
  213. /package/esm/{cli → core}/codegen/orm/barrel.d.ts +0 -0
  214. /package/esm/{cli → core}/codegen/orm/barrel.js +0 -0
  215. /package/esm/{cli → core}/codegen/orm/client-generator.d.ts +0 -0
  216. /package/esm/{cli → core}/codegen/orm/client.d.ts +0 -0
  217. /package/esm/{cli → core}/codegen/orm/client.js +0 -0
  218. /package/esm/{cli → core}/codegen/orm/custom-ops-generator.d.ts +0 -0
  219. /package/esm/{cli → core}/codegen/orm/custom-ops-generator.js +0 -0
  220. /package/esm/{cli → core}/codegen/orm/input-types-generator.d.ts +0 -0
  221. /package/esm/{cli → core}/codegen/orm/input-types-generator.js +0 -0
  222. /package/esm/{cli → core}/codegen/orm/model-generator.d.ts +0 -0
  223. /package/esm/{cli → core}/codegen/orm/model-generator.js +0 -0
  224. /package/esm/{cli → core}/codegen/orm/query-builder.d.ts +0 -0
  225. /package/esm/{cli → core}/codegen/orm/query-builder.js +0 -0
  226. /package/esm/{cli → core}/codegen/orm/select-types.d.ts +0 -0
  227. /package/esm/{cli → core}/codegen/orm/select-types.js +0 -0
  228. /package/esm/{cli → core}/codegen/queries.d.ts +0 -0
  229. /package/esm/{cli → core}/codegen/queries.js +0 -0
  230. /package/esm/{cli → core}/codegen/query-keys.js +0 -0
  231. /package/esm/{cli → core}/codegen/scalars.d.ts +0 -0
  232. /package/esm/{cli → core}/codegen/scalars.js +0 -0
  233. /package/esm/{cli → core}/codegen/schema-gql-ast.d.ts +0 -0
  234. /package/esm/{cli → core}/codegen/schema-gql-ast.js +0 -0
  235. /package/esm/{cli → core}/codegen/schema-types-generator.d.ts +0 -0
  236. /package/esm/{cli → core}/codegen/schema-types-generator.js +0 -0
  237. /package/esm/{cli → core}/codegen/type-resolver.d.ts +0 -0
  238. /package/esm/{cli → core}/codegen/type-resolver.js +0 -0
  239. /package/esm/{cli → core}/codegen/types.d.ts +0 -0
  240. /package/esm/{cli → core}/codegen/types.js +0 -0
  241. /package/esm/{cli → core}/codegen/utils.d.ts +0 -0
  242. /package/esm/{cli → core}/codegen/utils.js +0 -0
  243. /package/esm/{cli → core}/introspect/fetch-schema.d.ts +0 -0
  244. /package/esm/{cli → core}/introspect/index.d.ts +0 -0
  245. /package/esm/{cli → core}/introspect/index.js +0 -0
  246. /package/esm/{cli → core}/introspect/infer-tables.d.ts +0 -0
  247. /package/esm/{cli → core}/introspect/infer-tables.js +0 -0
  248. /package/esm/{cli → core}/introspect/schema-query.d.ts +0 -0
  249. /package/esm/{cli → core}/introspect/schema-query.js +0 -0
  250. /package/esm/{cli → core}/introspect/source/endpoint.d.ts +0 -0
  251. /package/esm/{cli → core}/introspect/source/endpoint.js +0 -0
  252. /package/esm/{cli → core}/introspect/source/file.d.ts +0 -0
  253. /package/esm/{cli → core}/introspect/source/file.js +0 -0
  254. /package/esm/{cli → core}/introspect/source/types.d.ts +0 -0
  255. /package/esm/{cli → core}/introspect/source/types.js +0 -0
  256. /package/esm/{cli → core}/introspect/transform-schema.d.ts +0 -0
  257. /package/esm/{cli → core}/introspect/transform-schema.js +0 -0
  258. /package/esm/{cli → core}/introspect/transform.d.ts +0 -0
  259. /package/esm/{cli → core}/introspect/transform.js +0 -0
  260. /package/esm/{cli → core}/watch/cache.d.ts +0 -0
  261. /package/esm/{cli → core}/watch/cache.js +0 -0
  262. /package/esm/{cli → core}/watch/debounce.d.ts +0 -0
  263. /package/esm/{cli → core}/watch/debounce.js +0 -0
  264. /package/esm/{cli → core}/watch/hash.d.ts +0 -0
  265. /package/esm/{cli → core}/watch/hash.js +0 -0
  266. /package/esm/{cli → core}/watch/index.d.ts +0 -0
  267. /package/esm/{cli → core}/watch/index.js +0 -0
  268. /package/esm/{cli → core}/watch/poller.d.ts +0 -0
  269. /package/esm/{cli → core}/watch/poller.js +0 -0
  270. /package/esm/{cli → core}/watch/types.js +0 -0
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * SDK Configuration types
3
3
  */
4
+ import type { PgConfig } from 'pg-env';
4
5
  /**
5
6
  * Entity relationship definition for cascade invalidation
6
7
  */
@@ -56,21 +57,84 @@ export interface QueryKeyConfig {
56
57
  */
57
58
  generateMutationKeys?: boolean;
58
59
  }
60
+ /**
61
+ * PGPM module configuration for ephemeral database creation
62
+ */
63
+ export interface PgpmConfig {
64
+ /**
65
+ * Path to a PGPM module directory
66
+ * Creates an ephemeral database, deploys the module, and introspects
67
+ */
68
+ modulePath?: string;
69
+ /**
70
+ * Path to a PGPM workspace directory
71
+ * Must be used together with `moduleName`
72
+ */
73
+ workspacePath?: string;
74
+ /**
75
+ * Name of the module within the PGPM workspace
76
+ * Must be used together with `workspacePath`
77
+ */
78
+ moduleName?: string;
79
+ }
80
+ /**
81
+ * Database configuration for direct database introspection
82
+ */
83
+ export interface DbConfig {
84
+ /**
85
+ * PostgreSQL connection configuration
86
+ * Falls back to environment variables (PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE)
87
+ * via @pgpmjs/env when not specified
88
+ */
89
+ config?: Partial<PgConfig>;
90
+ /**
91
+ * PGPM module configuration for ephemeral database creation
92
+ * When specified, creates an ephemeral database from the module
93
+ */
94
+ pgpm?: PgpmConfig;
95
+ /**
96
+ * PostgreSQL schemas to introspect
97
+ * Mutually exclusive with `apiNames`
98
+ * @example ['public', 'app_public']
99
+ */
100
+ schemas?: string[];
101
+ /**
102
+ * API names to resolve schemas from
103
+ * Queries services_public.api_schemas to automatically determine schemas
104
+ * Mutually exclusive with `schemas`
105
+ * @example ['my_api']
106
+ */
107
+ apiNames?: string[];
108
+ /**
109
+ * Keep the ephemeral database after introspection (for debugging)
110
+ * Only applies when using pgpm
111
+ * @default false
112
+ */
113
+ keepDb?: boolean;
114
+ }
59
115
  /**
60
116
  * Target configuration for graphql-codegen
61
117
  * Represents a single schema source and output destination.
118
+ *
119
+ * Source options (choose one):
120
+ * - endpoint: GraphQL endpoint URL for live introspection
121
+ * - schemaFile: Path to GraphQL schema file (.graphql)
122
+ * - db: Database configuration for direct introspection or PGPM module
62
123
  */
63
124
  export interface GraphQLSDKConfigTarget {
64
125
  /**
65
126
  * GraphQL endpoint URL for live introspection
66
- * Either endpoint or schema must be provided
67
127
  */
68
128
  endpoint?: string;
69
129
  /**
70
130
  * Path to GraphQL schema file (.graphql) for file-based generation
71
- * Either endpoint or schema must be provided
72
131
  */
73
- schema?: string;
132
+ schemaFile?: string;
133
+ /**
134
+ * Database configuration for direct database introspection or PGPM module
135
+ * Use db.schemas or db.apiNames to specify which schemas to introspect
136
+ */
137
+ db?: DbConfig;
74
138
  /**
75
139
  * Headers to include in introspection requests
76
140
  */
@@ -147,39 +211,18 @@ export interface GraphQLSDKConfigTarget {
147
211
  skipQueryField?: boolean;
148
212
  };
149
213
  /**
150
- * ORM client generation options
151
- * When set, generates a Prisma-like ORM client in addition to or instead of React Query hooks
152
- */
153
- orm?: {
154
- /**
155
- * Whether to generate ORM client
156
- * @default false
157
- */
158
- enabled?: boolean;
159
- /**
160
- * Output directory for generated ORM client
161
- * @default './generated/orm'
162
- */
163
- output?: string;
164
- /**
165
- * Whether to import shared types from hooks output or generate standalone
166
- * When true, ORM types.ts will re-export from ../graphql/types
167
- * @default true
168
- */
169
- useSharedTypes?: boolean;
170
- };
214
+ * Whether to generate ORM client
215
+ * When enabled, generates a Prisma-like ORM client to {output}/orm
216
+ * @default false
217
+ */
218
+ orm?: boolean;
171
219
  /**
172
- * React Query integration options
173
- * Controls whether React Query hooks are generated
220
+ * Whether to generate React Query hooks
221
+ * When enabled, generates React Query hooks to {output}/hooks
222
+ * When false, only standalone fetch functions are generated (no React dependency)
223
+ * @default false
174
224
  */
175
- reactQuery?: {
176
- /**
177
- * Whether to generate React Query hooks (useQuery, useMutation)
178
- * When false, only standalone fetch functions are generated (no React dependency)
179
- * @default false
180
- */
181
- enabled?: boolean;
182
- };
225
+ reactQuery?: boolean;
183
226
  /**
184
227
  * Query key generation configuration
185
228
  * Controls how query keys are structured for cache management
@@ -190,24 +233,31 @@ export interface GraphQLSDKConfigTarget {
190
233
  * When enabled via CLI --watch flag, the CLI will poll the endpoint for schema changes
191
234
  */
192
235
  watch?: WatchConfig;
193
- }
194
- /**
195
- * Multi-target configuration for graphql-codegen
196
- */
197
- export interface GraphQLSDKMultiConfig {
198
236
  /**
199
- * Shared defaults applied to every target
237
+ * Authorization header value (convenience option, also available in headers)
200
238
  */
201
- defaults?: GraphQLSDKConfigTarget;
239
+ authorization?: string;
202
240
  /**
203
- * Named target configurations
241
+ * Enable verbose output
242
+ * @default false
204
243
  */
205
- targets: Record<string, GraphQLSDKConfigTarget>;
244
+ verbose?: boolean;
245
+ /**
246
+ * Dry run - don't write files, just show what would be generated
247
+ * @default false
248
+ */
249
+ dryRun?: boolean;
250
+ /**
251
+ * Skip custom operations (only generate table CRUD)
252
+ * @default false
253
+ */
254
+ skipCustomOperations?: boolean;
206
255
  }
207
256
  /**
208
257
  * Main configuration type for graphql-codegen
258
+ * This is the same as GraphQLSDKConfigTarget - we keep the alias for clarity.
209
259
  */
210
- export type GraphQLSDKConfig = GraphQLSDKConfigTarget | GraphQLSDKMultiConfig;
260
+ export type GraphQLSDKConfig = GraphQLSDKConfigTarget;
211
261
  /**
212
262
  * Watch mode configuration options
213
263
  *
@@ -237,117 +287,30 @@ export interface WatchConfig {
237
287
  */
238
288
  clearScreen?: boolean;
239
289
  }
240
- /**
241
- * Resolved watch configuration with defaults applied
242
- */
243
- export interface ResolvedWatchConfig {
244
- pollInterval: number;
245
- debounce: number;
246
- touchFile: string | null;
247
- clearScreen: boolean;
248
- }
249
- /**
250
- * Resolved query key configuration with defaults applied
251
- */
252
- export interface ResolvedQueryKeyConfig {
253
- style: 'flat' | 'hierarchical';
254
- relationships: Record<string, EntityRelationship>;
255
- generateScopedKeys: boolean;
256
- generateCascadeHelpers: boolean;
257
- generateMutationKeys: boolean;
258
- }
259
- /**
260
- * Resolved configuration with defaults applied
261
- */
262
- export interface ResolvedConfig {
263
- /**
264
- * GraphQL endpoint URL (empty string if using schema file)
265
- */
266
- endpoint: string;
267
- /**
268
- * Path to GraphQL schema file (null if using endpoint)
269
- */
270
- schema: string | null;
271
- headers: Record<string, string>;
272
- output: string;
273
- tables: {
274
- include: string[];
275
- exclude: string[];
276
- systemExclude: string[];
277
- };
278
- queries: {
279
- include: string[];
280
- exclude: string[];
281
- systemExclude: string[];
282
- };
283
- mutations: {
284
- include: string[];
285
- exclude: string[];
286
- systemExclude: string[];
287
- };
288
- excludeFields: string[];
289
- hooks: {
290
- queries: boolean;
291
- mutations: boolean;
292
- queryKeyPrefix: string;
293
- };
294
- postgraphile: {
295
- schema: string;
296
- };
297
- codegen: {
298
- maxFieldDepth: number;
299
- skipQueryField: boolean;
300
- };
301
- orm: {
302
- enabled: boolean;
303
- output: string;
304
- useSharedTypes: boolean;
305
- };
306
- reactQuery: {
307
- enabled: boolean;
308
- };
309
- queryKeys: ResolvedQueryKeyConfig;
310
- watch: ResolvedWatchConfig;
311
- }
312
290
  /**
313
291
  * Default watch configuration values
314
292
  */
315
- export declare const DEFAULT_WATCH_CONFIG: ResolvedWatchConfig;
293
+ export declare const DEFAULT_WATCH_CONFIG: WatchConfig;
316
294
  /**
317
295
  * Default query key configuration values
318
296
  */
319
- export declare const DEFAULT_QUERY_KEY_CONFIG: ResolvedQueryKeyConfig;
297
+ export declare const DEFAULT_QUERY_KEY_CONFIG: QueryKeyConfig;
320
298
  /**
321
299
  * Default configuration values
322
300
  */
323
- export declare const DEFAULT_CONFIG: ResolvedConfig;
301
+ export declare const DEFAULT_CONFIG: GraphQLSDKConfigTarget;
324
302
  /**
325
303
  * Helper function to define configuration with type checking
326
304
  */
327
305
  export declare function defineConfig(config: GraphQLSDKConfig): GraphQLSDKConfig;
328
306
  /**
329
- * Resolved target configuration helper
330
- */
331
- export interface ResolvedTargetConfig {
332
- name: string;
333
- config: ResolvedConfig;
334
- }
335
- /**
336
- * Type guard for multi-target configs
337
- */
338
- export declare function isMultiConfig(config: GraphQLSDKConfig): config is GraphQLSDKMultiConfig;
339
- /**
340
- * Merge two target configs (defaults + overrides).
307
+ * Merge two configs (base + overrides).
341
308
  * Uses deepmerge with array replacement strategy - when a user specifies
342
309
  * an array like include: ['users'], it replaces the default ['*'] entirely.
343
310
  */
344
311
  export declare function mergeConfig(base: GraphQLSDKConfigTarget, overrides: GraphQLSDKConfigTarget): GraphQLSDKConfigTarget;
345
312
  /**
346
- * Resolve configuration by applying defaults.
347
- * Uses deepmerge with array replacement strategy.
348
- */
349
- export declare function resolveConfig(config: GraphQLSDKConfig): ResolvedConfig;
350
- /**
351
- * Resolve all targets in a multi-target config
313
+ * Get configuration options by merging defaults with user config.
314
+ * Similar to getEnvOptions pattern from @pgpmjs/env.
352
315
  */
353
- export declare function resolveConfigTargets(config: GraphQLSDKMultiConfig): ResolvedTargetConfig[];
316
+ export declare function getConfigOptions(overrides?: GraphQLSDKConfigTarget): GraphQLSDKConfigTarget;
@@ -14,7 +14,7 @@ const replaceArrays = (_target, source) => source;
14
14
  export const DEFAULT_WATCH_CONFIG = {
15
15
  pollInterval: 3000,
16
16
  debounce: 800,
17
- touchFile: null,
17
+ touchFile: undefined,
18
18
  clearScreen: true,
19
19
  };
20
20
  /**
@@ -32,7 +32,6 @@ export const DEFAULT_QUERY_KEY_CONFIG = {
32
32
  */
33
33
  export const DEFAULT_CONFIG = {
34
34
  endpoint: '',
35
- schema: null,
36
35
  headers: {},
37
36
  output: './generated/graphql',
38
37
  tables: {
@@ -63,14 +62,8 @@ export const DEFAULT_CONFIG = {
63
62
  maxFieldDepth: 2,
64
63
  skipQueryField: true,
65
64
  },
66
- orm: {
67
- enabled: false,
68
- output: './generated/orm',
69
- useSharedTypes: true,
70
- },
71
- reactQuery: {
72
- enabled: false,
73
- },
65
+ orm: false,
66
+ reactQuery: false,
74
67
  queryKeys: DEFAULT_QUERY_KEY_CONFIG,
75
68
  watch: DEFAULT_WATCH_CONFIG,
76
69
  };
@@ -81,14 +74,7 @@ export function defineConfig(config) {
81
74
  return config;
82
75
  }
83
76
  /**
84
- * Type guard for multi-target configs
85
- */
86
- export function isMultiConfig(config) {
87
- const targets = config.targets;
88
- return typeof targets === 'object' && targets !== null;
89
- }
90
- /**
91
- * Merge two target configs (defaults + overrides).
77
+ * Merge two configs (base + overrides).
92
78
  * Uses deepmerge with array replacement strategy - when a user specifies
93
79
  * an array like include: ['users'], it replaces the default ['*'] entirely.
94
80
  */
@@ -96,22 +82,9 @@ export function mergeConfig(base, overrides) {
96
82
  return deepmerge(base, overrides, { arrayMerge: replaceArrays });
97
83
  }
98
84
  /**
99
- * Resolve configuration by applying defaults.
100
- * Uses deepmerge with array replacement strategy.
101
- */
102
- export function resolveConfig(config) {
103
- if (isMultiConfig(config)) {
104
- throw new Error('Multi-target config cannot be resolved with resolveConfig(). Use resolveConfigTargets().');
105
- }
106
- return deepmerge(DEFAULT_CONFIG, config, { arrayMerge: replaceArrays });
107
- }
108
- /**
109
- * Resolve all targets in a multi-target config
85
+ * Get configuration options by merging defaults with user config.
86
+ * Similar to getEnvOptions pattern from @pgpmjs/env.
110
87
  */
111
- export function resolveConfigTargets(config) {
112
- const defaults = config.defaults ?? {};
113
- return Object.entries(config.targets).map(([name, target]) => ({
114
- name,
115
- config: resolveConfig(mergeConfig(defaults, target)),
116
- }));
88
+ export function getConfigOptions(overrides = {}) {
89
+ return deepmerge(DEFAULT_CONFIG, overrides, { arrayMerge: replaceArrays });
117
90
  }
@@ -5,5 +5,5 @@ export type { CleanTable, CleanField, CleanFieldType, CleanRelations, CleanBelon
5
5
  export type { PageInfo, ConnectionResult, QueryOptions, OrderByItem, FilterOperator, FieldFilter, RelationalFilter, Filter, } from './query';
6
6
  export type { MutationOptions, CreateInput, UpdateInput, DeleteInput, MutationResult, } from './mutation';
7
7
  export type { SimpleFieldSelection, FieldSelectionPreset, FieldSelection, SelectionOptions, } from './selection';
8
- export type { GraphQLSDKConfig, GraphQLSDKConfigTarget, GraphQLSDKMultiConfig, ResolvedConfig, ResolvedTargetConfig, } from './config';
9
- export { defineConfig, resolveConfig, resolveConfigTargets, DEFAULT_CONFIG, } from './config';
8
+ export type { GraphQLSDKConfig, GraphQLSDKConfigTarget, } from './config';
9
+ export { defineConfig, getConfigOptions, mergeConfig, DEFAULT_CONFIG, } from './config';
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Type exports for @constructive-io/graphql-codegen
3
3
  */
4
- export { defineConfig, resolveConfig, resolveConfigTargets, DEFAULT_CONFIG, } from './config';
4
+ export { defineConfig, getConfigOptions, mergeConfig, DEFAULT_CONFIG, } from './config';
package/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @constructive-io/graphql-codegen
3
3
  *
4
- * CLI-based GraphQL SDK generator for PostGraphile endpoints.
4
+ * GraphQL SDK generator for Constructive databases.
5
5
  * Introspects via _meta query and generates typed queries, mutations,
6
6
  * and React Query v5 hooks.
7
7
  */
@@ -10,5 +10,10 @@ export * from './core';
10
10
  export * from './generators';
11
11
  export * from './client';
12
12
  export { defineConfig } from './types/config';
13
- export { generateReactQuery, generateOrm, findConfigFile, loadConfigFile, } from './cli/commands';
14
- export type { GenerateOptions, GenerateResult, GenerateTargetResult, GenerateOrmOptions, GenerateOrmResult, GenerateOrmTargetResult, InitOptions, InitResult, } from './cli/commands';
13
+ export { generate } from './core/generate';
14
+ export type { GenerateOptions, GenerateResult } from './core/generate';
15
+ export { findConfigFile, loadConfigFile } from './core/config';
16
+ export { codegenQuestions, splitCommas, printResult } from './cli/shared';
17
+ export type { CodegenAnswers } from './cli/shared';
18
+ export { buildSchemaFromDatabase, buildSchemaSDLFromDatabase, } from './core/database';
19
+ export type { BuildSchemaFromDatabaseOptions, BuildSchemaFromDatabaseResult, } from './core/database';
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * @constructive-io/graphql-codegen
4
4
  *
5
- * CLI-based GraphQL SDK generator for PostGraphile endpoints.
5
+ * GraphQL SDK generator for Constructive databases.
6
6
  * Introspects via _meta query and generates typed queries, mutations,
7
7
  * and React Query v5 hooks.
8
8
  */
@@ -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.loadConfigFile = exports.findConfigFile = exports.generateOrm = exports.generateReactQuery = exports.defineConfig = void 0;
24
+ exports.buildSchemaSDLFromDatabase = exports.buildSchemaFromDatabase = exports.printResult = exports.splitCommas = exports.codegenQuestions = 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,9 +33,19 @@ __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
- // CLI command exports (for packages/cli consumption)
37
- var commands_1 = require("./cli/commands");
38
- Object.defineProperty(exports, "generateReactQuery", { enumerable: true, get: function () { return commands_1.generateReactQuery; } });
39
- Object.defineProperty(exports, "generateOrm", { enumerable: true, get: function () { return commands_1.generateOrm; } });
40
- Object.defineProperty(exports, "findConfigFile", { enumerable: true, get: function () { return commands_1.findConfigFile; } });
41
- Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return commands_1.loadConfigFile; } });
36
+ // Main generate function (orchestrates the entire pipeline)
37
+ var generate_1 = require("./core/generate");
38
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return generate_1.generate; } });
39
+ // Config utilities
40
+ var config_2 = require("./core/config");
41
+ Object.defineProperty(exports, "findConfigFile", { enumerable: true, get: function () { return config_2.findConfigFile; } });
42
+ Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return config_2.loadConfigFile; } });
43
+ // CLI shared utilities (for packages/cli to import)
44
+ var shared_1 = require("./cli/shared");
45
+ Object.defineProperty(exports, "codegenQuestions", { enumerable: true, get: function () { return shared_1.codegenQuestions; } });
46
+ Object.defineProperty(exports, "splitCommas", { enumerable: true, get: function () { return shared_1.splitCommas; } });
47
+ Object.defineProperty(exports, "printResult", { enumerable: true, get: function () { return shared_1.printResult; } });
48
+ // Database schema utilities (re-exported from core for convenience)
49
+ var database_1 = require("./core/database");
50
+ Object.defineProperty(exports, "buildSchemaFromDatabase", { enumerable: true, get: function () { return database_1.buildSchemaFromDatabase; } });
51
+ Object.defineProperty(exports, "buildSchemaSDLFromDatabase", { enumerable: true, get: function () { return database_1.buildSchemaSDLFromDatabase; } });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-codegen",
3
- "version": "2.32.0",
4
- "description": "CLI-based GraphQL SDK generator for PostGraphile endpoints with React Query hooks",
3
+ "version": "3.0.1",
4
+ "description": "GraphQL SDK generator for Constructive databases with React Query hooks",
5
5
  "keywords": [
6
6
  "graphql",
7
7
  "postgraphile",
@@ -35,19 +35,19 @@
35
35
  "scripts": {
36
36
  "clean": "makage clean",
37
37
  "prepack": "npm run build",
38
- "copy:ts": "makage copy src/cli/codegen/orm/query-builder.ts dist/cli/codegen/orm --flat",
38
+ "copy:ts": "makage copy src/core/codegen/orm/query-builder.ts dist/core/codegen/orm --flat",
39
39
  "build": "makage build && npm run copy:ts",
40
40
  "build:dev": "makage build --dev && npm run copy:ts",
41
41
  "dev": "ts-node ./src/index.ts",
42
42
  "lint": "eslint . --fix",
43
- "fmt": "prettier --write .",
44
- "fmt:check": "prettier --check .",
43
+ "fmt": "oxfmt --write .",
44
+ "fmt:check": "oxfmt --check .",
45
45
  "test": "jest --passWithNoTests",
46
46
  "test:watch": "jest --watch",
47
- "example:codegen:sdk": "tsx src/cli/index.ts generate --config examples/multi-target.config.ts",
48
- "example:codegen:orm": "tsx src/cli/index.ts generate-orm --config examples/multi-target.config.ts",
49
- "example:codegen:sdk:schema": "node dist/cli/index.js generate --schema examples/example.schema.graphql --output examples/output/generated-sdk-schema",
50
- "example:codegen:orm:schema": "node dist/cli/index.js generate-orm --schema examples/example.schema.graphql --output examples/output/generated-orm-schema",
47
+ "example:codegen:sdk": "tsx src/cli/index.ts --config examples/multi-target.config.ts --react-query",
48
+ "example:codegen:orm": "tsx src/cli/index.ts --config examples/multi-target.config.ts --orm",
49
+ "example:codegen:sdk:schema": "node dist/cli/index.js --schema-file examples/example.schema.graphql --output examples/output/generated-sdk-schema --react-query",
50
+ "example:codegen:orm:schema": "node dist/cli/index.js --schema-file examples/example.schema.graphql --output examples/output/generated-orm-schema --orm",
51
51
  "example:sdk": "tsx examples/react-hooks-sdk-test.tsx",
52
52
  "example:orm": "tsx examples/orm-sdk-test.ts",
53
53
  "example:sdk:typecheck": "tsc --noEmit --jsx react --esModuleInterop --skipLibCheck --moduleResolution node examples/react-hooks-sdk-test.tsx"
@@ -56,8 +56,10 @@
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.1",
59
60
  "@constructive-io/graphql-types": "^2.14.0",
60
61
  "@inquirerer/utils": "^3.2.0",
62
+ "@pgpmjs/core": "^5.0.0",
61
63
  "ajv": "^8.17.1",
62
64
  "deepmerge": "^4.3.1",
63
65
  "find-and-require-package-json": "^0.9.0",
@@ -66,7 +68,12 @@
66
68
  "inflekt": "^0.3.0",
67
69
  "inquirerer": "^4.4.0",
68
70
  "jiti": "^2.6.1",
69
- "prettier": "^3.7.4"
71
+ "oxfmt": "^0.26.0",
72
+ "pg-cache": "^2.0.0",
73
+ "pg-env": "^1.3.0",
74
+ "pgsql-client": "^2.0.0",
75
+ "pgsql-seed": "^1.0.0",
76
+ "undici": "^7.19.0"
70
77
  },
71
78
  "peerDependencies": {
72
79
  "@tanstack/react-query": "^5.0.0",
@@ -92,5 +99,5 @@
92
99
  "tsx": "^4.21.0",
93
100
  "typescript": "^5.9.3"
94
101
  },
95
- "gitHead": "39b5c59b01b8ce391dc14daf5a9430ca0ff67574"
102
+ "gitHead": "f6b4b738f0d069833af001a80b97d86fea6499ae"
96
103
  }