@graphql-tools/delegate 12.1.4 → 12.1.5-alpha-8f117bcbea98536ce3233d8bc38febf5e9a2ebe5
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 +13 -0
- package/dist/index.cjs +31 -24
- package/dist/index.d.cts +16 -12
- package/dist/index.d.ts +16 -12
- package/dist/index.js +30 -25
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @graphql-tools/delegate
|
|
2
2
|
|
|
3
|
+
## 12.1.5-alpha-8f117bcbea98536ce3233d8bc38febf5e9a2ebe5
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#2604](https://github.com/graphql-hive/gateway/pull/2604) [`19e4040`](https://github.com/graphql-hive/gateway/commit/19e404065a9d88215d1530749b43ce5e39262a56) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
|
|
9
|
+
|
|
10
|
+
- Updated dependency [`@graphql-tools/executor@^2.0.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/executor/v/2.0.1) (from `^1.4.13`, in `dependencies`)
|
|
11
|
+
- Updated dependency [`@graphql-tools/schema@^10.1.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/schema/v/10.1.1) (from `^10.0.29`, in `dependencies`)
|
|
12
|
+
- Updated dependency [`@graphql-tools/utils@^12.0.1` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/12.0.1) (from `^11.0.0`, in `dependencies`)
|
|
13
|
+
- Updated dependencies [[`19e4040`](https://github.com/graphql-hive/gateway/commit/19e404065a9d88215d1530749b43ce5e39262a56)]:
|
|
14
|
+
- @graphql-tools/batch-execute@10.1.1-alpha-8f117bcbea98536ce3233d8bc38febf5e9a2ebe5
|
|
15
|
+
|
|
3
16
|
## 12.1.4
|
|
4
17
|
### Patch Changes
|
|
5
18
|
|
package/dist/index.cjs
CHANGED
|
@@ -66,6 +66,15 @@ function getCoercedVariableValues(variableValues) {
|
|
|
66
66
|
}
|
|
67
67
|
return variableValues;
|
|
68
68
|
}
|
|
69
|
+
function getVariableValues(variableValues) {
|
|
70
|
+
if (variableValues != null && Object.hasOwn(variableValues, "coerced") && Object.hasOwn(variableValues, "sources")) {
|
|
71
|
+
return variableValues;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
coerced: variableValues ?? {},
|
|
75
|
+
sources: {}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
69
78
|
|
|
70
79
|
const prototypePollutingKeys = [
|
|
71
80
|
"__proto__",
|
|
@@ -75,22 +84,6 @@ const prototypePollutingKeys = [
|
|
|
75
84
|
function isPrototypePollutingKey(key) {
|
|
76
85
|
return prototypePollutingKeys.includes(key);
|
|
77
86
|
}
|
|
78
|
-
function removePrototypePollutingKeys(value) {
|
|
79
|
-
if (Array.isArray(value)) {
|
|
80
|
-
for (const item of value) {
|
|
81
|
-
removePrototypePollutingKeys(item);
|
|
82
|
-
}
|
|
83
|
-
} else if (value && typeof value === "object" && !(value instanceof Error)) {
|
|
84
|
-
for (const key of Object.keys(value)) {
|
|
85
|
-
if (isPrototypePollutingKey(key)) {
|
|
86
|
-
delete value[key];
|
|
87
|
-
} else {
|
|
88
|
-
removePrototypePollutingKeys(value[key]);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
87
|
|
|
95
88
|
const leftOverByDelegationPlan = /* @__PURE__ */ new WeakMap();
|
|
96
89
|
const PLAN_LEFT_OVER = Symbol("PLAN_LEFT_OVER");
|
|
@@ -163,7 +156,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
|
|
|
163
156
|
const { fields } = utils.collectFields(
|
|
164
157
|
schema,
|
|
165
158
|
info.fragments,
|
|
166
|
-
|
|
159
|
+
getVariableValues(info.variableValues),
|
|
167
160
|
type,
|
|
168
161
|
selectionSet
|
|
169
162
|
);
|
|
@@ -204,9 +197,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
|
|
|
204
197
|
continue;
|
|
205
198
|
}
|
|
206
199
|
const existingPropValue = object[responseKey];
|
|
207
|
-
const sourcePropValue =
|
|
208
|
-
resolverResult[responseKey]
|
|
209
|
-
);
|
|
200
|
+
const sourcePropValue = resolverResult[responseKey];
|
|
210
201
|
if (responseKey === "__typename" && existingPropValue !== sourcePropValue && graphql.isAbstractType(subschema.transformedSchema.getType(sourcePropValue))) {
|
|
211
202
|
continue;
|
|
212
203
|
}
|
|
@@ -576,7 +567,7 @@ function getResponseKey(info) {
|
|
|
576
567
|
`Data cannot be extracted from result without an explicit key or source schema.`
|
|
577
568
|
);
|
|
578
569
|
}
|
|
579
|
-
return
|
|
570
|
+
return info.fieldNodes[0].alias?.value ?? info.fieldName;
|
|
580
571
|
}
|
|
581
572
|
function getReturnType(info) {
|
|
582
573
|
if (info == null) {
|
|
@@ -2325,6 +2316,20 @@ function removeOverlappingAliases(result) {
|
|
|
2325
2316
|
return result;
|
|
2326
2317
|
}
|
|
2327
2318
|
|
|
2319
|
+
const asyncHelpers = {
|
|
2320
|
+
promiseAll: Promise.all.bind(Promise),
|
|
2321
|
+
track: () => void 0
|
|
2322
|
+
};
|
|
2323
|
+
function getGraphQLResolveInfo(info) {
|
|
2324
|
+
if (info == null || "getAbortSignal" in info && "getAsyncHelpers" in info) {
|
|
2325
|
+
return info;
|
|
2326
|
+
}
|
|
2327
|
+
return Object.assign(info, {
|
|
2328
|
+
getAbortSignal: () => void 0,
|
|
2329
|
+
getAsyncHelpers: () => asyncHelpers
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2328
2333
|
function getDelegatingOperation(parentType, schema) {
|
|
2329
2334
|
if (parentType === schema.getMutationType()) {
|
|
2330
2335
|
return "mutation";
|
|
@@ -2528,7 +2533,7 @@ function createRequest({
|
|
|
2528
2533
|
rootValue,
|
|
2529
2534
|
operationName: targetOperationName,
|
|
2530
2535
|
context,
|
|
2531
|
-
info,
|
|
2536
|
+
info: getGraphQLResolveInfo(info),
|
|
2532
2537
|
operationType: targetOperation
|
|
2533
2538
|
};
|
|
2534
2539
|
}
|
|
@@ -2574,7 +2579,7 @@ function defaultMergedResolver(parent, args, context, info) {
|
|
|
2574
2579
|
if (!parent) {
|
|
2575
2580
|
return null;
|
|
2576
2581
|
}
|
|
2577
|
-
const responseKey =
|
|
2582
|
+
const responseKey = info.fieldNodes[0].alias?.value ?? info.fieldName;
|
|
2578
2583
|
if (!isExternalObject(parent)) {
|
|
2579
2584
|
return graphql.defaultFieldResolver(parent, args, context, info);
|
|
2580
2585
|
}
|
|
@@ -3568,12 +3573,15 @@ exports.delegateToSchema = delegateToSchema;
|
|
|
3568
3573
|
exports.extractUnavailableFields = extractUnavailableFields;
|
|
3569
3574
|
exports.extractUnavailableFieldsFromSelectionSet = extractUnavailableFieldsFromSelectionSet;
|
|
3570
3575
|
exports.getActualFieldNodes = getActualFieldNodes;
|
|
3576
|
+
exports.getCoercedVariableValues = getCoercedVariableValues;
|
|
3571
3577
|
exports.getDelegatingOperation = getDelegatingOperation;
|
|
3578
|
+
exports.getGraphQLResolveInfo = getGraphQLResolveInfo;
|
|
3572
3579
|
exports.getPlanLeftOverFromParent = getPlanLeftOverFromParent;
|
|
3573
3580
|
exports.getSubschema = getSubschema;
|
|
3574
3581
|
exports.getTypeInfo = getTypeInfo;
|
|
3575
3582
|
exports.getTypeInfoWithType = getTypeInfoWithType;
|
|
3576
3583
|
exports.getUnpathedErrors = getUnpathedErrors;
|
|
3584
|
+
exports.getVariableValues = getVariableValues;
|
|
3577
3585
|
exports.handleOverrideByDelegation = handleOverrideByDelegation;
|
|
3578
3586
|
exports.handleResolverResult = handleResolverResult;
|
|
3579
3587
|
exports.isExternalObject = isExternalObject;
|
|
@@ -3582,6 +3590,5 @@ exports.isSubschema = isSubschema;
|
|
|
3582
3590
|
exports.isSubschemaConfig = isSubschemaConfig;
|
|
3583
3591
|
exports.leftOverByDelegationPlan = leftOverByDelegationPlan;
|
|
3584
3592
|
exports.mergeFields = mergeFields;
|
|
3585
|
-
exports.removePrototypePollutingKeys = removePrototypePollutingKeys;
|
|
3586
3593
|
exports.resolveExternalValue = resolveExternalValue;
|
|
3587
3594
|
exports.subtractSelectionSets = subtractSelectionSets;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExecutionRequest, ExecutionResult, Executor, Maybe, GraphQLResolveInfo as GraphQLResolveInfo$1 } from '@graphql-tools/utils';
|
|
1
|
+
import { ExecutionRequest, ExecutionResult, Executor, Maybe, VariableValues, GraphQLResolveInfo as GraphQLResolveInfo$1 } from '@graphql-tools/utils';
|
|
2
2
|
export { createDeferred } from '@graphql-tools/utils';
|
|
3
3
|
import * as graphql from 'graphql';
|
|
4
4
|
import { GraphQLSchema, OperationTypeNode, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, GraphQLFieldResolver, FragmentDefinitionNode, FieldNode, GraphQLNamedType, GraphQLObjectType, GraphQLField, GraphQLInterfaceType, SelectionNode, GraphQLNamedOutputType, TypeInfo, GraphQLType } from 'graphql';
|
|
@@ -232,19 +232,23 @@ declare function getPlanLeftOverFromParent(parent: any): DelegationPlanLeftOver
|
|
|
232
232
|
declare const getTypeInfo: (schema: GraphQLSchema) => TypeInfo;
|
|
233
233
|
declare const getTypeInfoWithType: (schema: GraphQLSchema, type: Maybe<GraphQLType>) => TypeInfo;
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
type PrototypePollutingKey = (typeof prototypePollutingKeys)[number];
|
|
237
|
-
declare function isPrototypePollutingKey(key: string): key is PrototypePollutingKey;
|
|
235
|
+
type VersionedVariableValues = Record<string, unknown> | VariableValues<Record<string, unknown>> | undefined;
|
|
238
236
|
/**
|
|
239
|
-
*
|
|
237
|
+
* Returns the runtime variable values, regardless of the graphql-js version.
|
|
240
238
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* `Function.prototype`, so the keys are dropped before any merge happens.
|
|
239
|
+
* - graphql <=16: `info.variableValues` is a flat `{ [name]: value }` map.
|
|
240
|
+
* - graphql >=17: `info.variableValues` is `{ sources, coerced }`; the runtime
|
|
241
|
+
* values live under `.coerced`.
|
|
245
242
|
*/
|
|
246
|
-
declare function
|
|
243
|
+
declare function getCoercedVariableValues(variableValues: VersionedVariableValues): Record<string, unknown> | undefined;
|
|
244
|
+
declare function getVariableValues(variableValues: VersionedVariableValues): VariableValues<Record<string, unknown>>;
|
|
245
|
+
|
|
246
|
+
declare function getGraphQLResolveInfo(info: GraphQLResolveInfo | undefined): GraphQLResolveInfo$1 | undefined;
|
|
247
|
+
|
|
248
|
+
declare const prototypePollutingKeys: readonly ["__proto__", "constructor", "prototype"];
|
|
249
|
+
type PrototypePollutingKey = (typeof prototypePollutingKeys)[number];
|
|
250
|
+
declare function isPrototypePollutingKey(key: string): key is PrototypePollutingKey;
|
|
247
251
|
|
|
248
|
-
declare const handleOverrideByDelegation: (info: GraphQLResolveInfo
|
|
252
|
+
declare const handleOverrideByDelegation: (info: GraphQLResolveInfo, context: any, overrideHandler: OverrideHandler) => boolean;
|
|
249
253
|
|
|
250
|
-
export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields,
|
|
254
|
+
export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getCoercedVariableValues, getDelegatingOperation, getGraphQLResolveInfo, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, getVariableValues, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExecutionRequest, ExecutionResult, Executor, Maybe, GraphQLResolveInfo as GraphQLResolveInfo$1 } from '@graphql-tools/utils';
|
|
1
|
+
import { ExecutionRequest, ExecutionResult, Executor, Maybe, VariableValues, GraphQLResolveInfo as GraphQLResolveInfo$1 } from '@graphql-tools/utils';
|
|
2
2
|
export { createDeferred } from '@graphql-tools/utils';
|
|
3
3
|
import * as graphql from 'graphql';
|
|
4
4
|
import { GraphQLSchema, OperationTypeNode, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, GraphQLFieldResolver, FragmentDefinitionNode, FieldNode, GraphQLNamedType, GraphQLObjectType, GraphQLField, GraphQLInterfaceType, SelectionNode, GraphQLNamedOutputType, TypeInfo, GraphQLType } from 'graphql';
|
|
@@ -232,19 +232,23 @@ declare function getPlanLeftOverFromParent(parent: any): DelegationPlanLeftOver
|
|
|
232
232
|
declare const getTypeInfo: (schema: GraphQLSchema) => TypeInfo;
|
|
233
233
|
declare const getTypeInfoWithType: (schema: GraphQLSchema, type: Maybe<GraphQLType>) => TypeInfo;
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
type PrototypePollutingKey = (typeof prototypePollutingKeys)[number];
|
|
237
|
-
declare function isPrototypePollutingKey(key: string): key is PrototypePollutingKey;
|
|
235
|
+
type VersionedVariableValues = Record<string, unknown> | VariableValues<Record<string, unknown>> | undefined;
|
|
238
236
|
/**
|
|
239
|
-
*
|
|
237
|
+
* Returns the runtime variable values, regardless of the graphql-js version.
|
|
240
238
|
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* `Function.prototype`, so the keys are dropped before any merge happens.
|
|
239
|
+
* - graphql <=16: `info.variableValues` is a flat `{ [name]: value }` map.
|
|
240
|
+
* - graphql >=17: `info.variableValues` is `{ sources, coerced }`; the runtime
|
|
241
|
+
* values live under `.coerced`.
|
|
245
242
|
*/
|
|
246
|
-
declare function
|
|
243
|
+
declare function getCoercedVariableValues(variableValues: VersionedVariableValues): Record<string, unknown> | undefined;
|
|
244
|
+
declare function getVariableValues(variableValues: VersionedVariableValues): VariableValues<Record<string, unknown>>;
|
|
245
|
+
|
|
246
|
+
declare function getGraphQLResolveInfo(info: GraphQLResolveInfo | undefined): GraphQLResolveInfo$1 | undefined;
|
|
247
|
+
|
|
248
|
+
declare const prototypePollutingKeys: readonly ["__proto__", "constructor", "prototype"];
|
|
249
|
+
type PrototypePollutingKey = (typeof prototypePollutingKeys)[number];
|
|
250
|
+
declare function isPrototypePollutingKey(key: string): key is PrototypePollutingKey;
|
|
247
251
|
|
|
248
|
-
declare const handleOverrideByDelegation: (info: GraphQLResolveInfo
|
|
252
|
+
declare const handleOverrideByDelegation: (info: GraphQLResolveInfo, context: any, overrideHandler: OverrideHandler) => boolean;
|
|
249
253
|
|
|
250
|
-
export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields,
|
|
254
|
+
export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getCoercedVariableValues, getDelegatingOperation, getGraphQLResolveInfo, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, getVariableValues, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memoize2, memoize1, collectFields, relocatedError, mergeDeep, promiseReduce, pathToArray,
|
|
1
|
+
import { memoize2, memoize1, collectFields, relocatedError, mergeDeep, promiseReduce, pathToArray, memoize3, getDefinedRootType, createGraphQLError, implementsAbstractType, getRootTypeNames, astFromArg, astFromValueUntyped, asArray, isAsyncIterable, getOperationASTFromRequest } from '@graphql-tools/utils';
|
|
2
2
|
export { createDeferred } from '@graphql-tools/utils';
|
|
3
3
|
import { GraphQLError, locatedError, isAbstractType, getNullableType, isLeafType, isCompositeType, isListType, responsePathAsArray, Kind, TypeInfo, versionInfo, visit, visitWithTypeInfo, isNullableType, isUnionType, getNamedType, isObjectType, isInterfaceType, typeFromAST, isTypeSubTypeOf, isNonNullType, isInputObjectType, defaultFieldResolver, isSchema, OperationTypeNode, validate } from 'graphql';
|
|
4
4
|
import { handleMaybePromise, isPromise, createDeferredPromise, mapAsyncIterator } from '@whatwg-node/promise-helpers';
|
|
@@ -66,6 +66,15 @@ function getCoercedVariableValues(variableValues) {
|
|
|
66
66
|
}
|
|
67
67
|
return variableValues;
|
|
68
68
|
}
|
|
69
|
+
function getVariableValues(variableValues) {
|
|
70
|
+
if (variableValues != null && Object.hasOwn(variableValues, "coerced") && Object.hasOwn(variableValues, "sources")) {
|
|
71
|
+
return variableValues;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
coerced: variableValues ?? {},
|
|
75
|
+
sources: {}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
69
78
|
|
|
70
79
|
const prototypePollutingKeys = [
|
|
71
80
|
"__proto__",
|
|
@@ -75,22 +84,6 @@ const prototypePollutingKeys = [
|
|
|
75
84
|
function isPrototypePollutingKey(key) {
|
|
76
85
|
return prototypePollutingKeys.includes(key);
|
|
77
86
|
}
|
|
78
|
-
function removePrototypePollutingKeys(value) {
|
|
79
|
-
if (Array.isArray(value)) {
|
|
80
|
-
for (const item of value) {
|
|
81
|
-
removePrototypePollutingKeys(item);
|
|
82
|
-
}
|
|
83
|
-
} else if (value && typeof value === "object" && !(value instanceof Error)) {
|
|
84
|
-
for (const key of Object.keys(value)) {
|
|
85
|
-
if (isPrototypePollutingKey(key)) {
|
|
86
|
-
delete value[key];
|
|
87
|
-
} else {
|
|
88
|
-
removePrototypePollutingKeys(value[key]);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
87
|
|
|
95
88
|
const leftOverByDelegationPlan = /* @__PURE__ */ new WeakMap();
|
|
96
89
|
const PLAN_LEFT_OVER = Symbol("PLAN_LEFT_OVER");
|
|
@@ -163,7 +156,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
|
|
|
163
156
|
const { fields } = collectFields(
|
|
164
157
|
schema,
|
|
165
158
|
info.fragments,
|
|
166
|
-
|
|
159
|
+
getVariableValues(info.variableValues),
|
|
167
160
|
type,
|
|
168
161
|
selectionSet
|
|
169
162
|
);
|
|
@@ -204,9 +197,7 @@ function handleResolverResult(resolverResult, subschema, selectionSet, object, c
|
|
|
204
197
|
continue;
|
|
205
198
|
}
|
|
206
199
|
const existingPropValue = object[responseKey];
|
|
207
|
-
const sourcePropValue =
|
|
208
|
-
resolverResult[responseKey]
|
|
209
|
-
);
|
|
200
|
+
const sourcePropValue = resolverResult[responseKey];
|
|
210
201
|
if (responseKey === "__typename" && existingPropValue !== sourcePropValue && isAbstractType(subschema.transformedSchema.getType(sourcePropValue))) {
|
|
211
202
|
continue;
|
|
212
203
|
}
|
|
@@ -576,7 +567,7 @@ function getResponseKey(info) {
|
|
|
576
567
|
`Data cannot be extracted from result without an explicit key or source schema.`
|
|
577
568
|
);
|
|
578
569
|
}
|
|
579
|
-
return
|
|
570
|
+
return info.fieldNodes[0].alias?.value ?? info.fieldName;
|
|
580
571
|
}
|
|
581
572
|
function getReturnType(info) {
|
|
582
573
|
if (info == null) {
|
|
@@ -2325,6 +2316,20 @@ function removeOverlappingAliases(result) {
|
|
|
2325
2316
|
return result;
|
|
2326
2317
|
}
|
|
2327
2318
|
|
|
2319
|
+
const asyncHelpers = {
|
|
2320
|
+
promiseAll: Promise.all.bind(Promise),
|
|
2321
|
+
track: () => void 0
|
|
2322
|
+
};
|
|
2323
|
+
function getGraphQLResolveInfo(info) {
|
|
2324
|
+
if (info == null || "getAbortSignal" in info && "getAsyncHelpers" in info) {
|
|
2325
|
+
return info;
|
|
2326
|
+
}
|
|
2327
|
+
return Object.assign(info, {
|
|
2328
|
+
getAbortSignal: () => void 0,
|
|
2329
|
+
getAsyncHelpers: () => asyncHelpers
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2328
2333
|
function getDelegatingOperation(parentType, schema) {
|
|
2329
2334
|
if (parentType === schema.getMutationType()) {
|
|
2330
2335
|
return "mutation";
|
|
@@ -2528,7 +2533,7 @@ function createRequest({
|
|
|
2528
2533
|
rootValue,
|
|
2529
2534
|
operationName: targetOperationName,
|
|
2530
2535
|
context,
|
|
2531
|
-
info,
|
|
2536
|
+
info: getGraphQLResolveInfo(info),
|
|
2532
2537
|
operationType: targetOperation
|
|
2533
2538
|
};
|
|
2534
2539
|
}
|
|
@@ -2574,7 +2579,7 @@ function defaultMergedResolver(parent, args, context, info) {
|
|
|
2574
2579
|
if (!parent) {
|
|
2575
2580
|
return null;
|
|
2576
2581
|
}
|
|
2577
|
-
const responseKey =
|
|
2582
|
+
const responseKey = info.fieldNodes[0].alias?.value ?? info.fieldName;
|
|
2578
2583
|
if (!isExternalObject(parent)) {
|
|
2579
2584
|
return defaultFieldResolver(parent, args, context, info);
|
|
2580
2585
|
}
|
|
@@ -3543,4 +3548,4 @@ function subtractSelectionSets(selectionSetA, selectionSetB, fragments = {}) {
|
|
|
3543
3548
|
};
|
|
3544
3549
|
}
|
|
3545
3550
|
|
|
3546
|
-
export { EMPTY_OBJECT, FIELD_SUBSCHEMA_MAP_SYMBOL, OBJECT_SUBSCHEMA_SYMBOL, PLAN_LEFT_OVER, Subschema, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields,
|
|
3551
|
+
export { EMPTY_OBJECT, FIELD_SUBSCHEMA_MAP_SYMBOL, OBJECT_SUBSCHEMA_SYMBOL, PLAN_LEFT_OVER, Subschema, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getCoercedVariableValues, getDelegatingOperation, getGraphQLResolveInfo, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, getVariableValues, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/delegate",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.5-alpha-8f117bcbea98536ce3233d8bc38febf5e9a2ebe5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@graphql-tools/batch-execute": "
|
|
42
|
-
"@graphql-tools/executor": "^
|
|
43
|
-
"@graphql-tools/schema": "^10.
|
|
44
|
-
"@graphql-tools/utils": "^
|
|
41
|
+
"@graphql-tools/batch-execute": "10.1.1-alpha-8f117bcbea98536ce3233d8bc38febf5e9a2ebe5",
|
|
42
|
+
"@graphql-tools/executor": "^2.0.1",
|
|
43
|
+
"@graphql-tools/schema": "^10.1.1",
|
|
44
|
+
"@graphql-tools/utils": "^12.0.1",
|
|
45
45
|
"@repeaterjs/repeater": "^3.0.6",
|
|
46
46
|
"@whatwg-node/promise-helpers": "^1.3.2",
|
|
47
47
|
"dataloader": "^2.2.3",
|