@graphql-tools/delegate 12.3.3 → 12.3.4
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/CHANGELOG.md +7 -0
- package/dist/index.cjs +27 -22
- package/dist/index.js +27 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @graphql-tools/delegate
|
|
2
2
|
|
|
3
|
+
## 12.3.4
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#2691](https://github.com/graphql-hive/gateway/pull/2691) [`3e0a896`](https://github.com/graphql-hive/gateway/commit/3e0a896cf110d8a6290e20b10b6865813301f5ca) Thanks [@jhonDoe15](https://github.com/jhonDoe15)! - Reduce allocation during delegation: clone HTTP query results only when the in-flight request has multiple consumers, construct compact fresh null-prototype field metadata maps, and avoid temporary fake-promise wrappers for synchronous composite completion. Preserve shared-request isolation, metadata descriptors, and asynchronous completion behavior.
|
|
9
|
+
|
|
3
10
|
## 12.3.3
|
|
4
11
|
### Patch Changes
|
|
5
12
|
|
package/dist/index.cjs
CHANGED
|
@@ -308,6 +308,8 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
const CompactFieldSubschemaMap = function CompactFieldSubschemaMap2() {
|
|
312
|
+
};
|
|
311
313
|
function resolveExternalValue(result, unpathedErrors, subschema, context, info, returnType = getReturnType$1(info), skipTypeMerging) {
|
|
312
314
|
const type = graphql.getNullableType(returnType);
|
|
313
315
|
if (result instanceof Error) {
|
|
@@ -323,28 +325,21 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
|
|
|
323
325
|
return null;
|
|
324
326
|
}
|
|
325
327
|
} else if (graphql.isCompositeType(type)) {
|
|
328
|
+
const resolved = resolveExternalObject(
|
|
329
|
+
type,
|
|
330
|
+
result,
|
|
331
|
+
unpathedErrors,
|
|
332
|
+
subschema,
|
|
333
|
+
context,
|
|
334
|
+
info,
|
|
335
|
+
skipTypeMerging
|
|
336
|
+
);
|
|
337
|
+
if (!promiseHelpers.isPromise(resolved)) {
|
|
338
|
+
return validateCompositeResult(resolved, type, info);
|
|
339
|
+
}
|
|
326
340
|
return promiseHelpers.handleMaybePromise(
|
|
327
|
-
() =>
|
|
328
|
-
|
|
329
|
-
result,
|
|
330
|
-
unpathedErrors,
|
|
331
|
-
subschema,
|
|
332
|
-
context,
|
|
333
|
-
info,
|
|
334
|
-
skipTypeMerging
|
|
335
|
-
),
|
|
336
|
-
(result2) => {
|
|
337
|
-
if (info && graphql.isAbstractType(type)) {
|
|
338
|
-
if (result2.__typename != null) {
|
|
339
|
-
const resolvedType = info.schema.getType(result2.__typename);
|
|
340
|
-
if (!resolvedType) {
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return result2;
|
|
345
|
-
}
|
|
346
|
-
return result2;
|
|
347
|
-
}
|
|
341
|
+
() => resolved,
|
|
342
|
+
(value) => validateCompositeResult(value, type, info)
|
|
348
343
|
);
|
|
349
344
|
} else if (graphql.isListType(type)) {
|
|
350
345
|
if (Array.isArray(result)) {
|
|
@@ -369,13 +364,23 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
|
|
|
369
364
|
);
|
|
370
365
|
}
|
|
371
366
|
}
|
|
367
|
+
function validateCompositeResult(value, type, info) {
|
|
368
|
+
if (info && graphql.isAbstractType(type)) {
|
|
369
|
+
if (value.__typename != null) {
|
|
370
|
+
const resolvedType = info.schema.getType(value.__typename);
|
|
371
|
+
if (!resolvedType) return null;
|
|
372
|
+
}
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
return value;
|
|
376
|
+
}
|
|
372
377
|
function resolveExternalObject(type, object, unpathedErrors, subschema, context, info, skipTypeMerging) {
|
|
373
378
|
if (!isExternalObject(object)) {
|
|
374
379
|
annotateExternalObject(
|
|
375
380
|
object,
|
|
376
381
|
unpathedErrors,
|
|
377
382
|
subschema,
|
|
378
|
-
|
|
383
|
+
Object.setPrototypeOf(new CompactFieldSubschemaMap(), null)
|
|
379
384
|
);
|
|
380
385
|
}
|
|
381
386
|
if (skipTypeMerging || info == null) {
|
package/dist/index.js
CHANGED
|
@@ -308,6 +308,8 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
const CompactFieldSubschemaMap = function CompactFieldSubschemaMap2() {
|
|
312
|
+
};
|
|
311
313
|
function resolveExternalValue(result, unpathedErrors, subschema, context, info, returnType = getReturnType$1(info), skipTypeMerging) {
|
|
312
314
|
const type = getNullableType(returnType);
|
|
313
315
|
if (result instanceof Error) {
|
|
@@ -323,28 +325,21 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
|
|
|
323
325
|
return null;
|
|
324
326
|
}
|
|
325
327
|
} else if (isCompositeType(type)) {
|
|
328
|
+
const resolved = resolveExternalObject(
|
|
329
|
+
type,
|
|
330
|
+
result,
|
|
331
|
+
unpathedErrors,
|
|
332
|
+
subschema,
|
|
333
|
+
context,
|
|
334
|
+
info,
|
|
335
|
+
skipTypeMerging
|
|
336
|
+
);
|
|
337
|
+
if (!isPromise(resolved)) {
|
|
338
|
+
return validateCompositeResult(resolved, type, info);
|
|
339
|
+
}
|
|
326
340
|
return handleMaybePromise(
|
|
327
|
-
() =>
|
|
328
|
-
|
|
329
|
-
result,
|
|
330
|
-
unpathedErrors,
|
|
331
|
-
subschema,
|
|
332
|
-
context,
|
|
333
|
-
info,
|
|
334
|
-
skipTypeMerging
|
|
335
|
-
),
|
|
336
|
-
(result2) => {
|
|
337
|
-
if (info && isAbstractType(type)) {
|
|
338
|
-
if (result2.__typename != null) {
|
|
339
|
-
const resolvedType = info.schema.getType(result2.__typename);
|
|
340
|
-
if (!resolvedType) {
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
return result2;
|
|
345
|
-
}
|
|
346
|
-
return result2;
|
|
347
|
-
}
|
|
341
|
+
() => resolved,
|
|
342
|
+
(value) => validateCompositeResult(value, type, info)
|
|
348
343
|
);
|
|
349
344
|
} else if (isListType(type)) {
|
|
350
345
|
if (Array.isArray(result)) {
|
|
@@ -369,13 +364,23 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
|
|
|
369
364
|
);
|
|
370
365
|
}
|
|
371
366
|
}
|
|
367
|
+
function validateCompositeResult(value, type, info) {
|
|
368
|
+
if (info && isAbstractType(type)) {
|
|
369
|
+
if (value.__typename != null) {
|
|
370
|
+
const resolvedType = info.schema.getType(value.__typename);
|
|
371
|
+
if (!resolvedType) return null;
|
|
372
|
+
}
|
|
373
|
+
return value;
|
|
374
|
+
}
|
|
375
|
+
return value;
|
|
376
|
+
}
|
|
372
377
|
function resolveExternalObject(type, object, unpathedErrors, subschema, context, info, skipTypeMerging) {
|
|
373
378
|
if (!isExternalObject(object)) {
|
|
374
379
|
annotateExternalObject(
|
|
375
380
|
object,
|
|
376
381
|
unpathedErrors,
|
|
377
382
|
subschema,
|
|
378
|
-
|
|
383
|
+
Object.setPrototypeOf(new CompactFieldSubschemaMap(), null)
|
|
379
384
|
);
|
|
380
385
|
}
|
|
381
386
|
if (skipTypeMerging || info == null) {
|