@constructive-io/graphql-codegen 4.4.2 → 4.5.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.
|
@@ -43,13 +43,20 @@ function isLocalhostSubdomain(hostname: string): boolean {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Make an HTTP/HTTPS request using native Node modules.
|
|
46
|
+
* Supports optional AbortSignal for request cancellation.
|
|
46
47
|
*/
|
|
47
48
|
function makeRequest(
|
|
48
49
|
url: URL,
|
|
49
50
|
options: http.RequestOptions,
|
|
50
51
|
body: string,
|
|
52
|
+
signal?: AbortSignal,
|
|
51
53
|
): Promise<HttpResponse> {
|
|
52
54
|
return new Promise((resolve, reject) => {
|
|
55
|
+
if (signal?.aborted) {
|
|
56
|
+
reject(new Error('The operation was aborted'));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
53
60
|
const protocol = url.protocol === 'https:' ? https : http;
|
|
54
61
|
|
|
55
62
|
const req = protocol.request(url, options, (res) => {
|
|
@@ -68,11 +75,33 @@ function makeRequest(
|
|
|
68
75
|
});
|
|
69
76
|
|
|
70
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
|
+
|
|
71
89
|
req.write(body);
|
|
72
90
|
req.end();
|
|
73
91
|
});
|
|
74
92
|
}
|
|
75
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
|
+
|
|
76
105
|
/**
|
|
77
106
|
* GraphQL adapter that uses node:http/node:https for requests.
|
|
78
107
|
*
|
|
@@ -94,12 +123,14 @@ export class NodeHttpAdapter implements GraphQLAdapter {
|
|
|
94
123
|
async execute<T>(
|
|
95
124
|
document: string,
|
|
96
125
|
variables?: Record<string, unknown>,
|
|
126
|
+
options?: NodeHttpExecuteOptions,
|
|
97
127
|
): Promise<QueryResult<T>> {
|
|
98
128
|
const requestUrl = new URL(this.url.href);
|
|
99
129
|
const requestHeaders: Record<string, string> = {
|
|
100
130
|
'Content-Type': 'application/json',
|
|
101
131
|
Accept: 'application/json',
|
|
102
132
|
...this.headers,
|
|
133
|
+
...options?.headers,
|
|
103
134
|
};
|
|
104
135
|
|
|
105
136
|
// For *.localhost subdomains, rewrite hostname and inject Host header
|
|
@@ -118,7 +149,12 @@ export class NodeHttpAdapter implements GraphQLAdapter {
|
|
|
118
149
|
headers: requestHeaders,
|
|
119
150
|
};
|
|
120
151
|
|
|
121
|
-
const response = await makeRequest(
|
|
152
|
+
const response = await makeRequest(
|
|
153
|
+
requestUrl,
|
|
154
|
+
requestOptions,
|
|
155
|
+
body,
|
|
156
|
+
options?.signal,
|
|
157
|
+
);
|
|
122
158
|
|
|
123
159
|
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
124
160
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
"@babel/types": "^7.28.6",
|
|
59
59
|
"@constructive-io/graphql-types": "^3.1.1",
|
|
60
60
|
"@inquirerer/utils": "^3.2.3",
|
|
61
|
-
"@pgpmjs/core": "^6.
|
|
61
|
+
"@pgpmjs/core": "^6.3.0",
|
|
62
62
|
"ajv": "^8.17.1",
|
|
63
63
|
"deepmerge": "^4.3.1",
|
|
64
64
|
"find-and-require-package-json": "^0.9.0",
|
|
65
65
|
"gql-ast": "^3.1.0",
|
|
66
|
-
"graphile-schema": "^1.2.
|
|
66
|
+
"graphile-schema": "^1.2.2",
|
|
67
67
|
"graphql": "^16.9.0",
|
|
68
68
|
"inflekt": "^0.3.1",
|
|
69
69
|
"inquirerer": "^4.4.0",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"oxfmt": "^0.26.0",
|
|
73
73
|
"pg-cache": "^3.1.0",
|
|
74
74
|
"pg-env": "^1.5.0",
|
|
75
|
-
"pgsql-client": "^3.2.
|
|
76
|
-
"pgsql-seed": "^2.2.
|
|
75
|
+
"pgsql-client": "^3.2.1",
|
|
76
|
+
"pgsql-seed": "^2.2.1",
|
|
77
77
|
"undici": "^7.19.0"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"tsx": "^4.21.0",
|
|
101
101
|
"typescript": "^5.9.3"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "594881150b097a4575f5dcdccf46207351d2a080"
|
|
104
104
|
}
|