@constructive-io/graphql-codegen 2.32.0 → 3.0.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 (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
package/types/config.d.ts CHANGED
@@ -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;
package/types/config.js CHANGED
@@ -8,10 +8,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.DEFAULT_CONFIG = exports.DEFAULT_QUERY_KEY_CONFIG = exports.DEFAULT_WATCH_CONFIG = void 0;
10
10
  exports.defineConfig = defineConfig;
11
- exports.isMultiConfig = isMultiConfig;
12
11
  exports.mergeConfig = mergeConfig;
13
- exports.resolveConfig = resolveConfig;
14
- exports.resolveConfigTargets = resolveConfigTargets;
12
+ exports.getConfigOptions = getConfigOptions;
15
13
  const deepmerge_1 = __importDefault(require("deepmerge"));
16
14
  /**
17
15
  * Array merge strategy that replaces arrays (source wins over target).
@@ -25,7 +23,7 @@ const replaceArrays = (_target, source) => source;
25
23
  exports.DEFAULT_WATCH_CONFIG = {
26
24
  pollInterval: 3000,
27
25
  debounce: 800,
28
- touchFile: null,
26
+ touchFile: undefined,
29
27
  clearScreen: true,
30
28
  };
31
29
  /**
@@ -43,7 +41,6 @@ exports.DEFAULT_QUERY_KEY_CONFIG = {
43
41
  */
44
42
  exports.DEFAULT_CONFIG = {
45
43
  endpoint: '',
46
- schema: null,
47
44
  headers: {},
48
45
  output: './generated/graphql',
49
46
  tables: {
@@ -74,14 +71,8 @@ exports.DEFAULT_CONFIG = {
74
71
  maxFieldDepth: 2,
75
72
  skipQueryField: true,
76
73
  },
77
- orm: {
78
- enabled: false,
79
- output: './generated/orm',
80
- useSharedTypes: true,
81
- },
82
- reactQuery: {
83
- enabled: false,
84
- },
74
+ orm: false,
75
+ reactQuery: false,
85
76
  queryKeys: exports.DEFAULT_QUERY_KEY_CONFIG,
86
77
  watch: exports.DEFAULT_WATCH_CONFIG,
87
78
  };
@@ -92,14 +83,7 @@ function defineConfig(config) {
92
83
  return config;
93
84
  }
94
85
  /**
95
- * Type guard for multi-target configs
96
- */
97
- function isMultiConfig(config) {
98
- const targets = config.targets;
99
- return typeof targets === 'object' && targets !== null;
100
- }
101
- /**
102
- * Merge two target configs (defaults + overrides).
86
+ * Merge two configs (base + overrides).
103
87
  * Uses deepmerge with array replacement strategy - when a user specifies
104
88
  * an array like include: ['users'], it replaces the default ['*'] entirely.
105
89
  */
@@ -107,22 +91,9 @@ function mergeConfig(base, overrides) {
107
91
  return (0, deepmerge_1.default)(base, overrides, { arrayMerge: replaceArrays });
108
92
  }
109
93
  /**
110
- * Resolve configuration by applying defaults.
111
- * Uses deepmerge with array replacement strategy.
112
- */
113
- function resolveConfig(config) {
114
- if (isMultiConfig(config)) {
115
- throw new Error('Multi-target config cannot be resolved with resolveConfig(). Use resolveConfigTargets().');
116
- }
117
- return (0, deepmerge_1.default)(exports.DEFAULT_CONFIG, config, { arrayMerge: replaceArrays });
118
- }
119
- /**
120
- * Resolve all targets in a multi-target config
94
+ * Get configuration options by merging defaults with user config.
95
+ * Similar to getEnvOptions pattern from @pgpmjs/env.
121
96
  */
122
- function resolveConfigTargets(config) {
123
- const defaults = config.defaults ?? {};
124
- return Object.entries(config.targets).map(([name, target]) => ({
125
- name,
126
- config: resolveConfig(mergeConfig(defaults, target)),
127
- }));
97
+ function getConfigOptions(overrides = {}) {
98
+ return (0, deepmerge_1.default)(exports.DEFAULT_CONFIG, overrides, { arrayMerge: replaceArrays });
128
99
  }
package/types/index.d.ts CHANGED
@@ -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';
package/types/index.js CHANGED
@@ -3,9 +3,9 @@
3
3
  * Type exports for @constructive-io/graphql-codegen
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_CONFIG = exports.resolveConfigTargets = exports.resolveConfig = exports.defineConfig = void 0;
6
+ exports.DEFAULT_CONFIG = exports.mergeConfig = exports.getConfigOptions = exports.defineConfig = void 0;
7
7
  var config_1 = require("./config");
8
8
  Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
9
- Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return config_1.resolveConfig; } });
10
- Object.defineProperty(exports, "resolveConfigTargets", { enumerable: true, get: function () { return config_1.resolveConfigTargets; } });
9
+ Object.defineProperty(exports, "getConfigOptions", { enumerable: true, get: function () { return config_1.getConfigOptions; } });
10
+ Object.defineProperty(exports, "mergeConfig", { enumerable: true, get: function () { return config_1.mergeConfig; } });
11
11
  Object.defineProperty(exports, "DEFAULT_CONFIG", { enumerable: true, get: function () { return config_1.DEFAULT_CONFIG; } });
@@ -1,53 +0,0 @@
1
- /**
2
- * Generate ORM command - generates Prisma-like ORM client from GraphQL schema
3
- *
4
- * This command:
5
- * 1. Fetches schema from endpoint or loads from file
6
- * 2. Infers table metadata from introspection (replaces _meta)
7
- * 3. Generates a Prisma-like ORM client with fluent API
8
- */
9
- export interface GenerateOrmOptions {
10
- /** Path to config file */
11
- config?: string;
12
- /** Named target in a multi-target config */
13
- target?: string;
14
- /** GraphQL endpoint URL (overrides config) */
15
- endpoint?: string;
16
- /** Path to GraphQL schema file (.graphql) */
17
- schema?: string;
18
- /** Output directory (overrides config) */
19
- output?: string;
20
- /** Authorization header */
21
- authorization?: string;
22
- /** Verbose output */
23
- verbose?: boolean;
24
- /** Dry run - don't write files */
25
- dryRun?: boolean;
26
- /** Skip custom operations (only generate table CRUD) */
27
- skipCustomOperations?: boolean;
28
- }
29
- export interface GenerateOrmTargetResult {
30
- name: string;
31
- output: string;
32
- success: boolean;
33
- message: string;
34
- tables?: string[];
35
- customQueries?: string[];
36
- customMutations?: string[];
37
- filesWritten?: string[];
38
- errors?: string[];
39
- }
40
- export interface GenerateOrmResult {
41
- success: boolean;
42
- message: string;
43
- targets?: GenerateOrmTargetResult[];
44
- tables?: string[];
45
- customQueries?: string[];
46
- customMutations?: string[];
47
- filesWritten?: string[];
48
- errors?: string[];
49
- }
50
- /**
51
- * Execute the generate-orm command (generates ORM client)
52
- */
53
- export declare function generateOrm(options?: GenerateOrmOptions): Promise<GenerateOrmResult>;