@graphql-tools/url-loader 7.5.1 → 7.5.3
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.
- package/index.js +22 -10
- package/index.mjs +22 -10
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -107,11 +107,13 @@ async function* handleReadable(readable) {
|
|
|
107
107
|
if (part) {
|
|
108
108
|
const eventStr = part.split('event: ')[1];
|
|
109
109
|
const dataStr = part.split('data: ')[1];
|
|
110
|
-
const data = JSON.parse(dataStr);
|
|
111
110
|
if (eventStr === 'complete') {
|
|
112
111
|
break outer;
|
|
113
112
|
}
|
|
114
|
-
|
|
113
|
+
if (dataStr) {
|
|
114
|
+
const data = JSON.parse(dataStr);
|
|
115
|
+
yield data.payload || data;
|
|
116
|
+
}
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
}
|
|
@@ -185,13 +187,16 @@ async function* handleReadableStream(stream) {
|
|
|
185
187
|
const line = buffer.subarray(lineStart, lineEnd);
|
|
186
188
|
if (line.length === 0) {
|
|
187
189
|
// empty line denotes end of message. Trigger the callback and start a new message:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
data
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
if (message.event || message.data) {
|
|
191
|
+
// NOT a server ping (":\n\n")
|
|
192
|
+
yield JSON.parse(message.data);
|
|
193
|
+
message = {
|
|
194
|
+
data: '',
|
|
195
|
+
event: '',
|
|
196
|
+
id: '',
|
|
197
|
+
retry: undefined,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
195
200
|
}
|
|
196
201
|
else if (fieldLength > 0) {
|
|
197
202
|
// exclude comments and lines with no values
|
|
@@ -386,7 +391,14 @@ class UrlLoader {
|
|
|
386
391
|
}
|
|
387
392
|
}
|
|
388
393
|
const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers, ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.headers) || {});
|
|
389
|
-
const
|
|
394
|
+
const acceptedProtocols = [`application/json`];
|
|
395
|
+
if (method === 'GET' && (options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === exports.SubscriptionProtocol.SSE) {
|
|
396
|
+
acceptedProtocols.push('text/event-stream');
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
acceptedProtocols.push('multipart/mixed');
|
|
400
|
+
}
|
|
401
|
+
const accept = acceptedProtocols.join(', ');
|
|
390
402
|
const query = graphql.print(request.document);
|
|
391
403
|
const requestBody = {
|
|
392
404
|
query,
|
package/index.mjs
CHANGED
|
@@ -82,11 +82,13 @@ async function* handleReadable(readable) {
|
|
|
82
82
|
if (part) {
|
|
83
83
|
const eventStr = part.split('event: ')[1];
|
|
84
84
|
const dataStr = part.split('data: ')[1];
|
|
85
|
-
const data = JSON.parse(dataStr);
|
|
86
85
|
if (eventStr === 'complete') {
|
|
87
86
|
break outer;
|
|
88
87
|
}
|
|
89
|
-
|
|
88
|
+
if (dataStr) {
|
|
89
|
+
const data = JSON.parse(dataStr);
|
|
90
|
+
yield data.payload || data;
|
|
91
|
+
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
}
|
|
@@ -160,13 +162,16 @@ async function* handleReadableStream(stream) {
|
|
|
160
162
|
const line = buffer.subarray(lineStart, lineEnd);
|
|
161
163
|
if (line.length === 0) {
|
|
162
164
|
// empty line denotes end of message. Trigger the callback and start a new message:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
data
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
if (message.event || message.data) {
|
|
166
|
+
// NOT a server ping (":\n\n")
|
|
167
|
+
yield JSON.parse(message.data);
|
|
168
|
+
message = {
|
|
169
|
+
data: '',
|
|
170
|
+
event: '',
|
|
171
|
+
id: '',
|
|
172
|
+
retry: undefined,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
176
|
else if (fieldLength > 0) {
|
|
172
177
|
// exclude comments and lines with no values
|
|
@@ -362,7 +367,14 @@ class UrlLoader {
|
|
|
362
367
|
}
|
|
363
368
|
}
|
|
364
369
|
const headers = Object.assign({}, options === null || options === void 0 ? void 0 : options.headers, ((_a = request.extensions) === null || _a === void 0 ? void 0 : _a.headers) || {});
|
|
365
|
-
const
|
|
370
|
+
const acceptedProtocols = [`application/json`];
|
|
371
|
+
if (method === 'GET' && (options === null || options === void 0 ? void 0 : options.subscriptionsProtocol) === SubscriptionProtocol.SSE) {
|
|
372
|
+
acceptedProtocols.push('text/event-stream');
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
acceptedProtocols.push('multipart/mixed');
|
|
376
|
+
}
|
|
377
|
+
const accept = acceptedProtocols.join(', ');
|
|
366
378
|
const query = print(request.document);
|
|
367
379
|
const requestBody = {
|
|
368
380
|
query,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/url-loader",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.3",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"@graphql-tools/delegate": "^8.4.1",
|
|
11
11
|
"@graphql-tools/utils": "^8.5.1",
|
|
12
12
|
"@graphql-tools/wrap": "^8.3.1",
|
|
13
|
-
"@n1ru4l/graphql-live-query": "0.
|
|
13
|
+
"@n1ru4l/graphql-live-query": "0.9.0",
|
|
14
14
|
"@types/websocket": "1.0.4",
|
|
15
15
|
"@types/ws": "^8.0.0",
|
|
16
|
-
"cross-undici-fetch": "^0.0.
|
|
16
|
+
"cross-undici-fetch": "^0.0.26",
|
|
17
17
|
"dset": "^3.1.0",
|
|
18
18
|
"extract-files": "11.0.0",
|
|
19
19
|
"graphql-sse": "^1.0.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"tslib": "~2.3.0",
|
|
26
26
|
"valid-url": "1.0.9",
|
|
27
27
|
"value-or-promise": "1.0.11",
|
|
28
|
-
"ws": "8.
|
|
28
|
+
"ws": "8.3.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|