@constructive-io/graphql-codegen 4.40.6 → 4.41.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 (45) hide show
  1. package/core/codegen/cli/executor-generator.d.ts +2 -6
  2. package/core/codegen/cli/executor-generator.js +12 -48
  3. package/core/codegen/cli/index.d.ts +0 -2
  4. package/core/codegen/cli/index.js +2 -16
  5. package/core/codegen/cli/table-command-generator.js +141 -2
  6. package/core/codegen/cli/utils-generator.d.ts +0 -8
  7. package/core/codegen/cli/utils-generator.js +0 -14
  8. package/core/codegen/mutation-keys.js +18 -0
  9. package/core/codegen/mutations.js +187 -0
  10. package/core/codegen/orm/client-generator.d.ts +1 -3
  11. package/core/codegen/orm/client-generator.js +1 -7
  12. package/core/codegen/orm/index.js +1 -1
  13. package/core/codegen/orm/model-generator.js +167 -5
  14. package/core/codegen/orm/select-types.d.ts +2 -1
  15. package/core/codegen/queries.js +1 -1
  16. package/core/codegen/templates/cli-utils.ts +4 -2
  17. package/core/codegen/templates/query-builder.ts +170 -1
  18. package/core/codegen/templates/select-types.ts +30 -1
  19. package/core/codegen/utils.d.ts +8 -0
  20. package/core/codegen/utils.js +39 -0
  21. package/core/generate.js +2 -19
  22. package/esm/core/codegen/cli/executor-generator.d.ts +2 -6
  23. package/esm/core/codegen/cli/executor-generator.js +12 -48
  24. package/esm/core/codegen/cli/index.d.ts +0 -2
  25. package/esm/core/codegen/cli/index.js +3 -17
  26. package/esm/core/codegen/cli/table-command-generator.js +141 -2
  27. package/esm/core/codegen/cli/utils-generator.d.ts +0 -8
  28. package/esm/core/codegen/cli/utils-generator.js +0 -13
  29. package/esm/core/codegen/mutation-keys.js +18 -0
  30. package/esm/core/codegen/mutations.js +188 -1
  31. package/esm/core/codegen/orm/client-generator.d.ts +1 -3
  32. package/esm/core/codegen/orm/client-generator.js +1 -7
  33. package/esm/core/codegen/orm/index.js +1 -1
  34. package/esm/core/codegen/orm/model-generator.js +168 -6
  35. package/esm/core/codegen/orm/select-types.d.ts +2 -1
  36. package/esm/core/codegen/queries.js +1 -1
  37. package/esm/core/codegen/utils.d.ts +8 -0
  38. package/esm/core/codegen/utils.js +31 -0
  39. package/esm/core/generate.js +2 -19
  40. package/esm/types/config.d.ts +0 -18
  41. package/esm/types/schema.d.ts +8 -0
  42. package/package.json +3 -3
  43. package/types/config.d.ts +0 -18
  44. package/types/schema.d.ts +8 -0
  45. package/core/codegen/templates/node-fetch.ts +0 -198
@@ -317,24 +317,6 @@ export interface GraphQLSDKConfigTarget {
317
317
  * @default false
318
318
  */
319
319
  orm?: boolean;
320
- /**
321
- * Enable NodeHttpAdapter generation for Node.js applications.
322
- * When true, generates a node-fetch.ts with NodeHttpAdapter (implements GraphQLAdapter)
323
- * using node:http/node:https for requests, enabling local development
324
- * with subdomain-based routing (e.g. auth.localhost:3000).
325
- * No global patching — the adapter is passed to createClient via the adapter option.
326
- *
327
- * When CLI generation is enabled (`cli: true`), this is auto-enabled unless
328
- * explicitly set to `false`.
329
- *
330
- * Can also be used standalone with the ORM client for any Node.js application:
331
- * ```ts
332
- * import { NodeHttpAdapter } from './orm/node-fetch';
333
- * const db = createClient({ adapter: new NodeHttpAdapter(endpoint, headers) });
334
- * ```
335
- * @default false
336
- */
337
- nodeHttpAdapter?: boolean;
338
320
  /**
339
321
  * Whether to generate React Query hooks
340
322
  * When enabled, generates React Query hooks to {output}/hooks
@@ -85,6 +85,14 @@ export interface TableQueryNames {
85
85
  delete: string | null;
86
86
  /** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
87
87
  patchFieldName?: string;
88
+ /** Bulk insert mutation name (e.g., "bulkCreateUsers") */
89
+ bulkInsert?: string | null;
90
+ /** Bulk upsert mutation name (e.g., "bulkUpsertUsers") */
91
+ bulkUpsert?: string | null;
92
+ /** Bulk update mutation name (e.g., "bulkUpdateUsers") */
93
+ bulkUpdate?: string | null;
94
+ /** Bulk delete mutation name (e.g., "bulkDeleteUsers") */
95
+ bulkDelete?: string | null;
88
96
  }
89
97
  /**
90
98
  * Table constraints
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-codegen",
3
- "version": "4.40.6",
3
+ "version": "4.41.1",
4
4
  "description": "GraphQL SDK generator for Constructive databases with React Query hooks",
5
5
  "keywords": [
6
6
  "graphql",
@@ -56,7 +56,7 @@
56
56
  "@0no-co/graphql.web": "^1.1.2",
57
57
  "@babel/generator": "^7.29.1",
58
58
  "@babel/types": "^7.29.0",
59
- "@constructive-io/graphql-query": "^3.23.4",
59
+ "@constructive-io/graphql-query": "^3.24.0",
60
60
  "@constructive-io/graphql-types": "^3.9.1",
61
61
  "@inquirerer/utils": "^3.3.5",
62
62
  "@pgpmjs/core": "^6.17.1",
@@ -100,5 +100,5 @@
100
100
  "tsx": "^4.21.0",
101
101
  "typescript": "^5.9.3"
102
102
  },
103
- "gitHead": "28b0b236e65b2a2228acad4fd840543c04b24825"
103
+ "gitHead": "0b23c8c5c65e408576cd1fe3e21b20ae6db8f492"
104
104
  }
package/types/config.d.ts CHANGED
@@ -317,24 +317,6 @@ export interface GraphQLSDKConfigTarget {
317
317
  * @default false
318
318
  */
319
319
  orm?: boolean;
320
- /**
321
- * Enable NodeHttpAdapter generation for Node.js applications.
322
- * When true, generates a node-fetch.ts with NodeHttpAdapter (implements GraphQLAdapter)
323
- * using node:http/node:https for requests, enabling local development
324
- * with subdomain-based routing (e.g. auth.localhost:3000).
325
- * No global patching — the adapter is passed to createClient via the adapter option.
326
- *
327
- * When CLI generation is enabled (`cli: true`), this is auto-enabled unless
328
- * explicitly set to `false`.
329
- *
330
- * Can also be used standalone with the ORM client for any Node.js application:
331
- * ```ts
332
- * import { NodeHttpAdapter } from './orm/node-fetch';
333
- * const db = createClient({ adapter: new NodeHttpAdapter(endpoint, headers) });
334
- * ```
335
- * @default false
336
- */
337
- nodeHttpAdapter?: boolean;
338
320
  /**
339
321
  * Whether to generate React Query hooks
340
322
  * When enabled, generates React Query hooks to {output}/hooks
package/types/schema.d.ts CHANGED
@@ -85,6 +85,14 @@ export interface TableQueryNames {
85
85
  delete: string | null;
86
86
  /** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
87
87
  patchFieldName?: string;
88
+ /** Bulk insert mutation name (e.g., "bulkCreateUsers") */
89
+ bulkInsert?: string | null;
90
+ /** Bulk upsert mutation name (e.g., "bulkUpsertUsers") */
91
+ bulkUpsert?: string | null;
92
+ /** Bulk update mutation name (e.g., "bulkUpdateUsers") */
93
+ bulkUpdate?: string | null;
94
+ /** Bulk delete mutation name (e.g., "bulkDeleteUsers") */
95
+ bulkDelete?: string | null;
88
96
  }
89
97
  /**
90
98
  * Table constraints
@@ -1,198 +0,0 @@
1
- /**
2
- * Node HTTP Adapter for Node.js applications
3
- *
4
- * Implements the GraphQLAdapter interface using node:http / node:https
5
- * instead of the Fetch API. This solves two Node.js limitations:
6
- *
7
- * 1. DNS: Node.js cannot resolve *.localhost subdomains (ENOTFOUND).
8
- * Browsers handle this automatically, but Node requires manual resolution.
9
- *
10
- * 2. Host header: The Fetch API treats "Host" as a forbidden request header
11
- * and silently drops it. The Constructive GraphQL server uses Host-header
12
- * subdomain routing (enableServicesApi), so this header must be preserved.
13
- *
14
- * By using node:http.request directly, both issues are bypassed cleanly
15
- * without any global patching.
16
- *
17
- * NOTE: This file is read at codegen time and written to output.
18
- * Any changes here will affect all generated CLI node adapters.
19
- */
20
-
21
- import http from 'node:http';
22
- import https from 'node:https';
23
-
24
- import type {
25
- GraphQLAdapter,
26
- GraphQLError,
27
- QueryResult,
28
- } from '@constructive-io/graphql-types';
29
-
30
- interface HttpResponse {
31
- statusCode: number;
32
- statusMessage: string;
33
- data: string;
34
- }
35
-
36
- /**
37
- * Check if a hostname is a localhost subdomain that needs special handling.
38
- * Returns true for *.localhost (e.g. auth.localhost) but not bare "localhost".
39
- */
40
- function isLocalhostSubdomain(hostname: string): boolean {
41
- return hostname.endsWith('.localhost') && hostname !== 'localhost';
42
- }
43
-
44
- /**
45
- * Make an HTTP/HTTPS request using native Node modules.
46
- * Supports optional AbortSignal for request cancellation.
47
- */
48
- function makeRequest(
49
- url: URL,
50
- options: http.RequestOptions,
51
- body: string,
52
- signal?: AbortSignal,
53
- ): Promise<HttpResponse> {
54
- return new Promise((resolve, reject) => {
55
- if (signal?.aborted) {
56
- reject(new Error('The operation was aborted'));
57
- return;
58
- }
59
-
60
- const protocol = url.protocol === 'https:' ? https : http;
61
-
62
- const req = protocol.request(url, options, (res) => {
63
- let data = '';
64
- res.setEncoding('utf8');
65
- res.on('data', (chunk: string) => {
66
- data += chunk;
67
- });
68
- res.on('end', () => {
69
- resolve({
70
- statusCode: res.statusCode || 0,
71
- statusMessage: res.statusMessage || '',
72
- data,
73
- });
74
- });
75
- });
76
-
77
- req.on('error', reject);
78
-
79
- if (signal) {
80
- const onAbort = () => {
81
- req.destroy(new Error('The operation was aborted'));
82
- };
83
- signal.addEventListener('abort', onAbort, { once: true });
84
- req.on('close', () => {
85
- signal.removeEventListener('abort', onAbort);
86
- });
87
- }
88
-
89
- req.write(body);
90
- req.end();
91
- });
92
- }
93
-
94
- /**
95
- * Options for individual execute calls.
96
- * Allows per-request header overrides and request cancellation.
97
- */
98
- export interface NodeHttpExecuteOptions {
99
- /** Additional headers to include in this request only */
100
- headers?: Record<string, string>;
101
- /** AbortSignal for request cancellation */
102
- signal?: AbortSignal;
103
- }
104
-
105
- /**
106
- * GraphQL adapter that uses node:http/node:https for requests.
107
- *
108
- * Handles *.localhost subdomains by rewriting the hostname to "localhost"
109
- * and injecting the original Host header for server-side subdomain routing.
110
- */
111
- export class NodeHttpAdapter implements GraphQLAdapter {
112
- private headers: Record<string, string>;
113
- private url: URL;
114
-
115
- constructor(
116
- private endpoint: string,
117
- headers?: Record<string, string>,
118
- ) {
119
- this.headers = headers ?? {};
120
- this.url = new URL(endpoint);
121
- }
122
-
123
- async execute<T>(
124
- document: string,
125
- variables?: Record<string, unknown>,
126
- options?: NodeHttpExecuteOptions,
127
- ): Promise<QueryResult<T>> {
128
- const requestUrl = new URL(this.url.href);
129
- const requestHeaders: Record<string, string> = {
130
- 'Content-Type': 'application/json',
131
- Accept: 'application/json',
132
- ...this.headers,
133
- ...options?.headers,
134
- };
135
-
136
- // For *.localhost subdomains, rewrite hostname and inject Host header
137
- if (isLocalhostSubdomain(requestUrl.hostname)) {
138
- requestHeaders['Host'] = requestUrl.host;
139
- requestUrl.hostname = 'localhost';
140
- }
141
-
142
- const body = JSON.stringify({
143
- query: document,
144
- variables: variables ?? {},
145
- });
146
-
147
- const requestOptions: http.RequestOptions = {
148
- method: 'POST',
149
- headers: requestHeaders,
150
- };
151
-
152
- const response = await makeRequest(
153
- requestUrl,
154
- requestOptions,
155
- body,
156
- options?.signal,
157
- );
158
-
159
- if (response.statusCode < 200 || response.statusCode >= 300) {
160
- return {
161
- ok: false,
162
- data: null,
163
- errors: [
164
- {
165
- message: `HTTP ${response.statusCode}: ${response.statusMessage}`,
166
- },
167
- ],
168
- };
169
- }
170
-
171
- const json = JSON.parse(response.data) as {
172
- data?: T;
173
- errors?: GraphQLError[];
174
- };
175
-
176
- if (json.errors && json.errors.length > 0) {
177
- return {
178
- ok: false,
179
- data: null,
180
- errors: json.errors,
181
- };
182
- }
183
-
184
- return {
185
- ok: true,
186
- data: json.data as T,
187
- errors: undefined,
188
- };
189
- }
190
-
191
- setHeaders(headers: Record<string, string>): void {
192
- this.headers = { ...this.headers, ...headers };
193
- }
194
-
195
- getEndpoint(): string {
196
- return this.endpoint;
197
- }
198
- }