@graphql-tools/delegate 10.0.0-rc-20230519104353-b09f3180 → 10.0.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.
package/cjs/Subschema.js CHANGED
@@ -8,19 +8,17 @@ function isSubschema(value) {
8
8
  exports.isSubschema = isSubschema;
9
9
  class Subschema {
10
10
  constructor(config) {
11
- var _a;
12
11
  this.schema = config.schema;
13
12
  this.executor = config.executor;
14
13
  this.batch = config.batch;
15
14
  this.batchingOptions = config.batchingOptions;
16
15
  this.createProxyingResolver = config.createProxyingResolver;
17
- this.transforms = (_a = config.transforms) !== null && _a !== void 0 ? _a : [];
16
+ this.transforms = config.transforms ?? [];
18
17
  this.merge = config.merge;
19
18
  }
20
19
  get transformedSchema() {
21
- var _a, _b;
22
20
  if (!this._transformedSchema) {
23
- if (((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b['DEBUG']) != null) {
21
+ if (globalThis.process?.env?.['DEBUG'] != null) {
24
22
  console.warn('Transformed schema is not set yet. Returning a dummy one.');
25
23
  }
26
24
  this._transformedSchema = (0, applySchemaTransforms_js_1.applySchemaTransforms)(this.schema, this);
@@ -18,10 +18,9 @@ class Transformer {
18
18
  this.transformations.push({ transform, context });
19
19
  }
20
20
  transformRequest(originalRequest) {
21
- var _a;
22
21
  let request = {
23
22
  ...originalRequest,
24
- document: (0, prepareGatewayDocument_js_1.prepareGatewayDocument)(originalRequest.document, this.delegationContext.transformedSchema, this.delegationContext.returnType, (_a = this.delegationContext.info) === null || _a === void 0 ? void 0 : _a.schema),
23
+ document: (0, prepareGatewayDocument_js_1.prepareGatewayDocument)(originalRequest.document, this.delegationContext.transformedSchema, this.delegationContext.returnType, this.delegationContext.info?.schema),
25
24
  };
26
25
  for (const transformation of this.transformations) {
27
26
  if (transformation.transform.transformRequest) {
@@ -8,5 +8,5 @@ exports.applySchemaTransforms = (0, utils_1.memoize2)(function applySchemaTransf
8
8
  if (schemaTransforms == null) {
9
9
  return originalWrappingSchema;
10
10
  }
11
- return schemaTransforms.reduce((schema, transform) => { var _a; return ((_a = transform.transformSchema) === null || _a === void 0 ? void 0 : _a.call(transform, schema, subschemaConfig)) || schema; }, originalWrappingSchema);
11
+ return schemaTransforms.reduce((schema, transform) => transform.transformSchema?.(schema, subschemaConfig) || schema, originalWrappingSchema);
12
12
  });
@@ -16,7 +16,6 @@ result = {
16
16
  }
17
17
  exports.checkResultAndHandleErrors = checkResultAndHandleErrors;
18
18
  function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
19
- var _a;
20
19
  if (data == null) {
21
20
  if (!errors.length) {
22
21
  return { data: null, unpathedErrors: [] };
@@ -40,7 +39,7 @@ function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
40
39
  const unpathedErrors = [];
41
40
  const errorMap = new Map();
42
41
  for (const error of errors) {
43
- const pathSegment = (_a = error.path) === null || _a === void 0 ? void 0 : _a[index];
42
+ const pathSegment = error.path?.[index];
44
43
  if (pathSegment != null) {
45
44
  let pathSegmentErrors = errorMap.get(pathSegment);
46
45
  if (pathSegmentErrors === undefined) {
@@ -14,7 +14,6 @@ function getDelegatingOperation(parentType, schema) {
14
14
  }
15
15
  exports.getDelegatingOperation = getDelegatingOperation;
16
16
  function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragments, variableDefinitions, variableValues, targetRootValue, targetOperationName, targetOperation, targetFieldName, selectionSet, fieldNodes, context, info, }) {
17
- var _a, _b;
18
17
  let newSelectionSet;
19
18
  const argumentNodeMap = Object.create(null);
20
19
  if (selectionSet != null) {
@@ -35,7 +34,7 @@ function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragme
35
34
  selections,
36
35
  }
37
36
  : undefined;
38
- const args = (_a = fieldNodes === null || fieldNodes === void 0 ? void 0 : fieldNodes[0]) === null || _a === void 0 ? void 0 : _a.arguments;
37
+ const args = fieldNodes?.[0]?.arguments;
39
38
  if (args) {
40
39
  for (const argNode of args) {
41
40
  argumentNodeMap[argNode.name.value] = argNode;
@@ -49,7 +48,7 @@ function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragme
49
48
  const varName = def.variable.name.value;
50
49
  variableDefinitionMap[varName] = def;
51
50
  const varType = (0, graphql_1.typeFromAST)(sourceSchema, def.type);
52
- const serializedValue = (0, utils_1.serializeInputValue)(varType, variableValues === null || variableValues === void 0 ? void 0 : variableValues[varName]);
51
+ const serializedValue = (0, utils_1.serializeInputValue)(varType, variableValues?.[varName]);
53
52
  if (serializedValue !== undefined) {
54
53
  newVariables[varName] = serializedValue;
55
54
  }
@@ -58,7 +57,7 @@ function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragme
58
57
  if (sourceParentType != null && sourceFieldName != null) {
59
58
  updateArgumentsWithDefaults(sourceParentType, sourceFieldName, argumentNodeMap, variableDefinitionMap, newVariables);
60
59
  }
61
- const rootFieldName = targetFieldName !== null && targetFieldName !== void 0 ? targetFieldName : (_b = fieldNodes === null || fieldNodes === void 0 ? void 0 : fieldNodes[0]) === null || _b === void 0 ? void 0 : _b.name.value;
60
+ const rootFieldName = targetFieldName ?? fieldNodes?.[0]?.name.value;
62
61
  if (rootFieldName === undefined) {
63
62
  throw new Error(`Either "targetFieldName" or a non empty "fieldNodes" array must be provided.`);
64
63
  }
@@ -12,8 +12,7 @@ const Transformer_js_1 = require("./Transformer.js");
12
12
  const applySchemaTransforms_js_1 = require("./applySchemaTransforms.js");
13
13
  const executor_1 = require("@graphql-tools/executor");
14
14
  function delegateToSchema(options) {
15
- var _a, _b;
16
- const { info, schema, rootValue = (_a = schema.rootValue) !== null && _a !== void 0 ? _a : info.rootValue, operationName = (_b = info.operation.name) === null || _b === void 0 ? void 0 : _b.value, operation = (0, createRequest_js_1.getDelegatingOperation)(info.parentType, info.schema), fieldName = info.fieldName, selectionSet, fieldNodes = info.fieldNodes, context, } = options;
15
+ const { info, schema, rootValue = schema.rootValue ?? info.rootValue, operationName = info.operation.name?.value, operation = (0, createRequest_js_1.getDelegatingOperation)(info.parentType, info.schema), fieldName = info.fieldName, selectionSet, fieldNodes = info.fieldNodes, context, } = options;
17
16
  const request = (0, createRequest_js_1.createRequest)({
18
17
  sourceSchema: info.schema,
19
18
  sourceParentType: info.parentType,
@@ -65,7 +64,6 @@ function delegateRequest(options) {
65
64
  }
66
65
  exports.delegateRequest = delegateRequest;
67
66
  function getDelegationContext({ request, schema, fieldName, returnType, args, info, transforms = [], transformedSchema, skipTypeMerging = false, }) {
68
- var _a, _b, _c, _d;
69
67
  const operationDefinition = (0, utils_1.getOperationASTFromRequest)(request);
70
68
  let targetFieldName;
71
69
  if (fieldName == null) {
@@ -74,8 +72,8 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
74
72
  else {
75
73
  targetFieldName = fieldName;
76
74
  }
77
- const stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a['stitchingInfo'];
78
- const subschemaOrSubschemaConfig = (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.subschemaMap.get(schema)) !== null && _b !== void 0 ? _b : schema;
75
+ const stitchingInfo = info?.schema.extensions?.['stitchingInfo'];
76
+ const subschemaOrSubschemaConfig = stitchingInfo?.subschemaMap.get(schema) ?? schema;
79
77
  const operation = operationDefinition.operation;
80
78
  if ((0, subschemaConfig_js_1.isSubschemaConfig)(subschemaOrSubschemaConfig)) {
81
79
  const targetSchema = subschemaOrSubschemaConfig.schema;
@@ -88,13 +86,14 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
88
86
  args,
89
87
  context: request.context,
90
88
  info,
91
- returnType: (_c = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _c !== void 0 ? _c : getDelegationReturnType(targetSchema, operation, targetFieldName),
89
+ returnType: returnType ?? info?.returnType ?? getDelegationReturnType(targetSchema, operation, targetFieldName),
92
90
  transforms: subschemaOrSubschemaConfig.transforms != null
93
91
  ? subschemaOrSubschemaConfig.transforms.concat(transforms)
94
92
  : transforms,
95
- transformedSchema: transformedSchema !== null && transformedSchema !== void 0 ? transformedSchema : (subschemaOrSubschemaConfig instanceof Subschema_js_1.Subschema
96
- ? subschemaOrSubschemaConfig.transformedSchema
97
- : (0, applySchemaTransforms_js_1.applySchemaTransforms)(targetSchema, subschemaOrSubschemaConfig)),
93
+ transformedSchema: transformedSchema ??
94
+ (subschemaOrSubschemaConfig instanceof Subschema_js_1.Subschema
95
+ ? subschemaOrSubschemaConfig.transformedSchema
96
+ : (0, applySchemaTransforms_js_1.applySchemaTransforms)(targetSchema, subschemaOrSubschemaConfig)),
98
97
  skipTypeMerging,
99
98
  };
100
99
  }
@@ -107,9 +106,9 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
107
106
  args,
108
107
  context: request.context,
109
108
  info,
110
- returnType: (_d = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _d !== void 0 ? _d : getDelegationReturnType(subschemaOrSubschemaConfig, operation, targetFieldName),
109
+ returnType: returnType ?? info?.returnType ?? getDelegationReturnType(subschemaOrSubschemaConfig, operation, targetFieldName),
111
110
  transforms,
112
- transformedSchema: transformedSchema !== null && transformedSchema !== void 0 ? transformedSchema : subschemaOrSubschemaConfig,
111
+ transformedSchema: transformedSchema ?? subschemaOrSubschemaConfig,
113
112
  skipTypeMerging,
114
113
  };
115
114
  }
@@ -127,10 +126,10 @@ function validateRequest(delegationContext, document) {
127
126
  const GLOBAL_CONTEXT = {};
128
127
  function getExecutor(delegationContext) {
129
128
  const { subschemaConfig, targetSchema, context } = delegationContext;
130
- let executor = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.executor) || (0, exports.createDefaultExecutor)(targetSchema);
131
- if (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batch) {
132
- const batchingOptions = subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batchingOptions;
133
- executor = (0, batch_execute_1.getBatchingExecutor)(context !== null && context !== void 0 ? context : GLOBAL_CONTEXT, executor, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.dataLoaderOptions, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.extensionsReducer);
129
+ let executor = subschemaConfig?.executor || (0, exports.createDefaultExecutor)(targetSchema);
130
+ if (subschemaConfig?.batch) {
131
+ const batchingOptions = subschemaConfig?.batchingOptions;
132
+ executor = (0, batch_execute_1.getBatchingExecutor)(context ?? GLOBAL_CONTEXT, executor, batchingOptions?.dataLoaderOptions, batchingOptions?.extensionsReducer);
134
133
  }
135
134
  return executor;
136
135
  }
@@ -5,7 +5,6 @@ const graphql_1 = require("graphql");
5
5
  const utils_1 = require("@graphql-tools/utils");
6
6
  const getDocumentMetadata_js_1 = require("./getDocumentMetadata.js");
7
7
  function finalizeGatewayDocument(targetSchema, fragments, operations) {
8
- var _a;
9
8
  let usedVariables = [];
10
9
  let usedFragments = [];
11
10
  const newOperations = [];
@@ -30,7 +29,7 @@ function finalizeGatewayDocument(targetSchema, fragments, operations) {
30
29
  usedVariables = union(usedVariables, operationOrFragmentVariables);
31
30
  newFragments = collectedNewFragments;
32
31
  fragmentSet = collectedFragmentSet;
33
- const variableDefinitions = ((_a = operation.variableDefinitions) !== null && _a !== void 0 ? _a : []).filter((variable) => operationOrFragmentVariables.indexOf(variable.variable.name.value) !== -1);
32
+ const variableDefinitions = (operation.variableDefinitions ?? []).filter((variable) => operationOrFragmentVariables.indexOf(variable.variable.name.value) !== -1);
34
33
  newOperations.push({
35
34
  kind: graphql_1.Kind.OPERATION_DEFINITION,
36
35
  operation: operation.operation,
@@ -56,7 +55,7 @@ function finalizeGatewayRequest(originalRequest, delegationContext) {
56
55
  if (args) {
57
56
  const requestWithNewVariables = addVariablesToRootFields(targetSchema, operations, args);
58
57
  operations = requestWithNewVariables.newOperations;
59
- variables = Object.assign({}, variables !== null && variables !== void 0 ? variables : {}, requestWithNewVariables.newVariables);
58
+ variables = Object.assign({}, variables ?? {}, requestWithNewVariables.newVariables);
60
59
  }
61
60
  const { usedVariables, newDocument } = finalizeGatewayDocument(targetSchema, fragments, operations);
62
61
  const newVariables = {};
@@ -78,8 +77,7 @@ exports.finalizeGatewayRequest = finalizeGatewayRequest;
78
77
  function addVariablesToRootFields(targetSchema, operations, args) {
79
78
  const newVariables = Object.create(null);
80
79
  const newOperations = operations.map((operation) => {
81
- var _a, _b;
82
- const variableDefinitionMap = ((_a = operation.variableDefinitions) !== null && _a !== void 0 ? _a : []).reduce((prev, def) => ({
80
+ const variableDefinitionMap = (operation.variableDefinitions ?? []).reduce((prev, def) => ({
83
81
  ...prev,
84
82
  [def.variable.name.value]: def,
85
83
  }), {});
@@ -87,7 +85,7 @@ function addVariablesToRootFields(targetSchema, operations, args) {
87
85
  const newSelections = [];
88
86
  for (const selection of operation.selectionSet.selections) {
89
87
  if (selection.kind === graphql_1.Kind.FIELD) {
90
- const argumentNodes = (_b = selection.arguments) !== null && _b !== void 0 ? _b : [];
88
+ const argumentNodes = selection.arguments ?? [];
91
89
  const argumentNodeMap = argumentNodes.reduce((prev, argument) => ({
92
90
  ...prev,
93
91
  [argument.name.value]: argument,
@@ -19,8 +19,7 @@ function annotateExternalObject(object, errors, subschema, subschemaMap) {
19
19
  }
20
20
  exports.annotateExternalObject = annotateExternalObject;
21
21
  function getSubschema(object, responseKey) {
22
- var _a;
23
- return (_a = object[symbols_js_1.FIELD_SUBSCHEMA_MAP_SYMBOL][responseKey]) !== null && _a !== void 0 ? _a : object[symbols_js_1.OBJECT_SUBSCHEMA_SYMBOL];
22
+ return object[symbols_js_1.FIELD_SUBSCHEMA_MAP_SYMBOL][responseKey] ?? object[symbols_js_1.OBJECT_SUBSCHEMA_SYMBOL];
24
23
  }
25
24
  exports.getSubschema = getSubschema;
26
25
  function getUnpathedErrors(object) {
@@ -36,8 +35,7 @@ exports.getActualFieldNodes = (0, utils_1.memoize1)(function (fieldNode) {
36
35
  return [fieldNode];
37
36
  });
38
37
  function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
39
- var _a;
40
- const delegationMaps = mergedTypeInfo.delegationPlanBuilder(info.schema, sourceSubschema, info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT, info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT, ((_a = info.fieldNodes) === null || _a === void 0 ? void 0 : _a.length)
38
+ const delegationMaps = mergedTypeInfo.delegationPlanBuilder(info.schema, sourceSubschema, info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT, info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT, info.fieldNodes?.length
41
39
  ? info.fieldNodes.length === 1
42
40
  ? (0, exports.getActualFieldNodes)(info.fieldNodes[0])
43
41
  : info.fieldNodes
@@ -50,7 +48,6 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
50
48
  const path = (0, graphql_1.responsePathAsArray)(info.path);
51
49
  const combinedFieldSubschemaMap = object[symbols_js_1.FIELD_SUBSCHEMA_MAP_SYMBOL];
52
50
  function finallyFn(source, subschema, selectionSet) {
53
- var _a;
54
51
  if (source instanceof Error || source == null) {
55
52
  const schema = subschema.transformedSchema || info.schema;
56
53
  const type = schema.getType(object.__typename);
@@ -83,7 +80,7 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
83
80
  if (sourcePropValue != null || existingPropValue == null) {
84
81
  object[responseKey] = sourcePropValue;
85
82
  }
86
- combinedFieldSubschemaMap[responseKey] = (_a = fieldSubschemaMap === null || fieldSubschemaMap === void 0 ? void 0 : fieldSubschemaMap[responseKey]) !== null && _a !== void 0 ? _a : objectSubschema;
83
+ combinedFieldSubschemaMap[responseKey] = fieldSubschemaMap?.[responseKey] ?? objectSubschema;
87
84
  }
88
85
  }
89
86
  return value_or_promise_1.ValueOrPromise.all([...delegationMap.entries()].map(([subschema, selectionSet]) => new value_or_promise_1.ValueOrPromise(() => {
@@ -35,7 +35,6 @@ function prepareGatewayDocument(originalDocument, transformedSchema, returnType,
35
35
  }
36
36
  exports.prepareGatewayDocument = prepareGatewayDocument;
37
37
  function visitSelectionSet(node, fragmentReplacements, schema, typeInfo, possibleTypesMap, reversePossibleTypesMap, interfaceExtensionsMap, fieldNodesByType, fieldNodesByField, dynamicSelectionSetsByField) {
38
- var _a, _b;
39
38
  const newSelections = new Set();
40
39
  const maybeType = typeInfo.getParentType();
41
40
  if (maybeType != null) {
@@ -87,13 +86,13 @@ function visitSelectionSet(node, fragmentReplacements, schema, typeInfo, possibl
87
86
  }
88
87
  else {
89
88
  const fieldName = selection.name.value;
90
- const fieldNodes = (_a = fieldNodesByField[parentTypeName]) === null || _a === void 0 ? void 0 : _a[fieldName];
89
+ const fieldNodes = fieldNodesByField[parentTypeName]?.[fieldName];
91
90
  if (fieldNodes != null) {
92
91
  for (const fieldNode of fieldNodes) {
93
92
  newSelections.add(fieldNode);
94
93
  }
95
94
  }
96
- const dynamicSelectionSets = (_b = dynamicSelectionSetsByField[parentTypeName]) === null || _b === void 0 ? void 0 : _b[fieldName];
95
+ const dynamicSelectionSets = dynamicSelectionSetsByField[parentTypeName]?.[fieldName];
97
96
  if (dynamicSelectionSets != null) {
98
97
  for (const selectionSetFn of dynamicSelectionSets) {
99
98
  const selectionSet = selectionSetFn(selection);
@@ -104,7 +103,7 @@ function visitSelectionSet(node, fragmentReplacements, schema, typeInfo, possibl
104
103
  }
105
104
  }
106
105
  }
107
- if (interfaceExtensions === null || interfaceExtensions === void 0 ? void 0 : interfaceExtensions[fieldName]) {
106
+ if (interfaceExtensions?.[fieldName]) {
108
107
  interfaceExtensionFields.push(selection);
109
108
  }
110
109
  else {
@@ -153,7 +152,6 @@ function generateInlineFragment(typeName, selectionSet) {
153
152
  };
154
153
  }
155
154
  const getSchemaMetaData = (0, utils_1.memoize2)((sourceSchema, targetSchema) => {
156
- var _a, _b, _c, _d;
157
155
  const typeMap = sourceSchema.getTypeMap();
158
156
  const targetTypeMap = targetSchema.getTypeMap();
159
157
  const possibleTypesMap = Object.create(null);
@@ -188,14 +186,14 @@ const getSchemaMetaData = (0, utils_1.memoize2)((sourceSchema, targetSchema) =>
188
186
  }
189
187
  }
190
188
  }
191
- const stitchingInfo = (_a = sourceSchema.extensions) === null || _a === void 0 ? void 0 : _a['stitchingInfo'];
189
+ const stitchingInfo = sourceSchema.extensions?.['stitchingInfo'];
192
190
  return {
193
191
  possibleTypesMap,
194
192
  reversePossibleTypesMap: reversePossibleTypesMap(possibleTypesMap),
195
193
  interfaceExtensionsMap,
196
- fieldNodesByType: (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.fieldNodesByType) !== null && _b !== void 0 ? _b : {},
197
- fieldNodesByField: (_c = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.fieldNodesByField) !== null && _c !== void 0 ? _c : {},
198
- dynamicSelectionSetsByField: (_d = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.dynamicSelectionSetsByField) !== null && _d !== void 0 ? _d : {},
194
+ fieldNodesByType: stitchingInfo?.fieldNodesByType ?? {},
195
+ fieldNodesByField: stitchingInfo?.fieldNodesByField ?? {},
196
+ dynamicSelectionSetsByField: stitchingInfo?.dynamicSelectionSetsByField ?? {},
199
197
  };
200
198
  });
201
199
  function reversePossibleTypesMap(possibleTypesMap) {
@@ -26,7 +26,6 @@ function resolveExternalValue(result, unpathedErrors, subschema, context, info,
26
26
  }
27
27
  exports.resolveExternalValue = resolveExternalValue;
28
28
  function resolveExternalObject(type, object, unpathedErrors, subschema, context, info, skipTypeMerging) {
29
- var _a;
30
29
  // if we have already resolved this object, for example, when the identical object appears twice
31
30
  // in a list, see https://github.com/ardatan/graphql-tools/issues/2304
32
31
  if (!(0, mergeFields_js_1.isExternalObject)(object)) {
@@ -35,7 +34,7 @@ function resolveExternalObject(type, object, unpathedErrors, subschema, context,
35
34
  if (skipTypeMerging || info == null) {
36
35
  return object;
37
36
  }
38
- const stitchingInfo = (_a = info.schema.extensions) === null || _a === void 0 ? void 0 : _a['stitchingInfo'];
37
+ const stitchingInfo = info.schema.extensions?.['stitchingInfo'];
39
38
  if (stitchingInfo == null) {
40
39
  return object;
41
40
  }
@@ -2,11 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cloneSubschemaConfig = exports.isSubschemaConfig = void 0;
4
4
  function isSubschemaConfig(value) {
5
- return Boolean(value === null || value === void 0 ? void 0 : value.schema);
5
+ return Boolean(value?.schema);
6
6
  }
7
7
  exports.isSubschemaConfig = isSubschemaConfig;
8
8
  function cloneSubschemaConfig(subschemaConfig) {
9
- var _a, _b;
10
9
  const newSubschemaConfig = {
11
10
  ...subschemaConfig,
12
11
  transforms: subschemaConfig.transforms != null ? [...subschemaConfig.transforms] : undefined,
@@ -14,7 +13,7 @@ function cloneSubschemaConfig(subschemaConfig) {
14
13
  if (newSubschemaConfig.merge != null) {
15
14
  newSubschemaConfig.merge = { ...subschemaConfig.merge };
16
15
  for (const typeName in newSubschemaConfig.merge) {
17
- const mergedTypeConfig = (newSubschemaConfig.merge[typeName] = { ...((_b = (_a = subschemaConfig.merge) === null || _a === void 0 ? void 0 : _a[typeName]) !== null && _b !== void 0 ? _b : {}) });
16
+ const mergedTypeConfig = (newSubschemaConfig.merge[typeName] = { ...(subschemaConfig.merge?.[typeName] ?? {}) });
18
17
  if (mergedTypeConfig.entryPoints != null) {
19
18
  mergedTypeConfig.entryPoints = mergedTypeConfig.entryPoints.map(entryPoint => ({ ...entryPoint }));
20
19
  }
package/esm/Subschema.js CHANGED
@@ -4,19 +4,17 @@ export function isSubschema(value) {
4
4
  }
5
5
  export class Subschema {
6
6
  constructor(config) {
7
- var _a;
8
7
  this.schema = config.schema;
9
8
  this.executor = config.executor;
10
9
  this.batch = config.batch;
11
10
  this.batchingOptions = config.batchingOptions;
12
11
  this.createProxyingResolver = config.createProxyingResolver;
13
- this.transforms = (_a = config.transforms) !== null && _a !== void 0 ? _a : [];
12
+ this.transforms = config.transforms ?? [];
14
13
  this.merge = config.merge;
15
14
  }
16
15
  get transformedSchema() {
17
- var _a, _b;
18
16
  if (!this._transformedSchema) {
19
- if (((_b = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env) === null || _b === void 0 ? void 0 : _b['DEBUG']) != null) {
17
+ if (globalThis.process?.env?.['DEBUG'] != null) {
20
18
  console.warn('Transformed schema is not set yet. Returning a dummy one.');
21
19
  }
22
20
  this._transformedSchema = applySchemaTransforms(this.schema, this);
@@ -15,10 +15,9 @@ export class Transformer {
15
15
  this.transformations.push({ transform, context });
16
16
  }
17
17
  transformRequest(originalRequest) {
18
- var _a;
19
18
  let request = {
20
19
  ...originalRequest,
21
- document: prepareGatewayDocument(originalRequest.document, this.delegationContext.transformedSchema, this.delegationContext.returnType, (_a = this.delegationContext.info) === null || _a === void 0 ? void 0 : _a.schema),
20
+ document: prepareGatewayDocument(originalRequest.document, this.delegationContext.transformedSchema, this.delegationContext.returnType, this.delegationContext.info?.schema),
22
21
  };
23
22
  for (const transformation of this.transformations) {
24
23
  if (transformation.transform.transformRequest) {
@@ -5,5 +5,5 @@ export const applySchemaTransforms = memoize2(function applySchemaTransforms(ori
5
5
  if (schemaTransforms == null) {
6
6
  return originalWrappingSchema;
7
7
  }
8
- return schemaTransforms.reduce((schema, transform) => { var _a; return ((_a = transform.transformSchema) === null || _a === void 0 ? void 0 : _a.call(transform, schema, subschemaConfig)) || schema; }, originalWrappingSchema);
8
+ return schemaTransforms.reduce((schema, transform) => transform.transformSchema?.(schema, subschemaConfig) || schema, originalWrappingSchema);
9
9
  });
@@ -12,7 +12,6 @@ result = {
12
12
  return resolveExternalValue(data, unpathedErrors, subschema, context, info, returnType, skipTypeMerging);
13
13
  }
14
14
  export function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1) {
15
- var _a;
16
15
  if (data == null) {
17
16
  if (!errors.length) {
18
17
  return { data: null, unpathedErrors: [] };
@@ -36,7 +35,7 @@ export function mergeDataAndErrors(data, errors, path, onLocatedError, index = 1
36
35
  const unpathedErrors = [];
37
36
  const errorMap = new Map();
38
37
  for (const error of errors) {
39
- const pathSegment = (_a = error.path) === null || _a === void 0 ? void 0 : _a[index];
38
+ const pathSegment = error.path?.[index];
40
39
  if (pathSegment != null) {
41
40
  let pathSegmentErrors = errorMap.get(pathSegment);
42
41
  if (pathSegmentErrors === undefined) {
@@ -10,7 +10,6 @@ export function getDelegatingOperation(parentType, schema) {
10
10
  return 'query';
11
11
  }
12
12
  export function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragments, variableDefinitions, variableValues, targetRootValue, targetOperationName, targetOperation, targetFieldName, selectionSet, fieldNodes, context, info, }) {
13
- var _a, _b;
14
13
  let newSelectionSet;
15
14
  const argumentNodeMap = Object.create(null);
16
15
  if (selectionSet != null) {
@@ -31,7 +30,7 @@ export function createRequest({ sourceSchema, sourceParentType, sourceFieldName,
31
30
  selections,
32
31
  }
33
32
  : undefined;
34
- const args = (_a = fieldNodes === null || fieldNodes === void 0 ? void 0 : fieldNodes[0]) === null || _a === void 0 ? void 0 : _a.arguments;
33
+ const args = fieldNodes?.[0]?.arguments;
35
34
  if (args) {
36
35
  for (const argNode of args) {
37
36
  argumentNodeMap[argNode.name.value] = argNode;
@@ -45,7 +44,7 @@ export function createRequest({ sourceSchema, sourceParentType, sourceFieldName,
45
44
  const varName = def.variable.name.value;
46
45
  variableDefinitionMap[varName] = def;
47
46
  const varType = typeFromAST(sourceSchema, def.type);
48
- const serializedValue = serializeInputValue(varType, variableValues === null || variableValues === void 0 ? void 0 : variableValues[varName]);
47
+ const serializedValue = serializeInputValue(varType, variableValues?.[varName]);
49
48
  if (serializedValue !== undefined) {
50
49
  newVariables[varName] = serializedValue;
51
50
  }
@@ -54,7 +53,7 @@ export function createRequest({ sourceSchema, sourceParentType, sourceFieldName,
54
53
  if (sourceParentType != null && sourceFieldName != null) {
55
54
  updateArgumentsWithDefaults(sourceParentType, sourceFieldName, argumentNodeMap, variableDefinitionMap, newVariables);
56
55
  }
57
- const rootFieldName = targetFieldName !== null && targetFieldName !== void 0 ? targetFieldName : (_b = fieldNodes === null || fieldNodes === void 0 ? void 0 : fieldNodes[0]) === null || _b === void 0 ? void 0 : _b.name.value;
56
+ const rootFieldName = targetFieldName ?? fieldNodes?.[0]?.name.value;
58
57
  if (rootFieldName === undefined) {
59
58
  throw new Error(`Either "targetFieldName" or a non empty "fieldNodes" array must be provided.`);
60
59
  }
@@ -9,8 +9,7 @@ import { Transformer } from './Transformer.js';
9
9
  import { applySchemaTransforms } from './applySchemaTransforms.js';
10
10
  import { normalizedExecutor } from '@graphql-tools/executor';
11
11
  export function delegateToSchema(options) {
12
- var _a, _b;
13
- const { info, schema, rootValue = (_a = schema.rootValue) !== null && _a !== void 0 ? _a : info.rootValue, operationName = (_b = info.operation.name) === null || _b === void 0 ? void 0 : _b.value, operation = getDelegatingOperation(info.parentType, info.schema), fieldName = info.fieldName, selectionSet, fieldNodes = info.fieldNodes, context, } = options;
12
+ const { info, schema, rootValue = schema.rootValue ?? info.rootValue, operationName = info.operation.name?.value, operation = getDelegatingOperation(info.parentType, info.schema), fieldName = info.fieldName, selectionSet, fieldNodes = info.fieldNodes, context, } = options;
14
13
  const request = createRequest({
15
14
  sourceSchema: info.schema,
16
15
  sourceParentType: info.parentType,
@@ -60,7 +59,6 @@ export function delegateRequest(options) {
60
59
  .resolve();
61
60
  }
62
61
  function getDelegationContext({ request, schema, fieldName, returnType, args, info, transforms = [], transformedSchema, skipTypeMerging = false, }) {
63
- var _a, _b, _c, _d;
64
62
  const operationDefinition = getOperationASTFromRequest(request);
65
63
  let targetFieldName;
66
64
  if (fieldName == null) {
@@ -69,8 +67,8 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
69
67
  else {
70
68
  targetFieldName = fieldName;
71
69
  }
72
- const stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a['stitchingInfo'];
73
- const subschemaOrSubschemaConfig = (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.subschemaMap.get(schema)) !== null && _b !== void 0 ? _b : schema;
70
+ const stitchingInfo = info?.schema.extensions?.['stitchingInfo'];
71
+ const subschemaOrSubschemaConfig = stitchingInfo?.subschemaMap.get(schema) ?? schema;
74
72
  const operation = operationDefinition.operation;
75
73
  if (isSubschemaConfig(subschemaOrSubschemaConfig)) {
76
74
  const targetSchema = subschemaOrSubschemaConfig.schema;
@@ -83,13 +81,14 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
83
81
  args,
84
82
  context: request.context,
85
83
  info,
86
- returnType: (_c = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _c !== void 0 ? _c : getDelegationReturnType(targetSchema, operation, targetFieldName),
84
+ returnType: returnType ?? info?.returnType ?? getDelegationReturnType(targetSchema, operation, targetFieldName),
87
85
  transforms: subschemaOrSubschemaConfig.transforms != null
88
86
  ? subschemaOrSubschemaConfig.transforms.concat(transforms)
89
87
  : transforms,
90
- transformedSchema: transformedSchema !== null && transformedSchema !== void 0 ? transformedSchema : (subschemaOrSubschemaConfig instanceof Subschema
91
- ? subschemaOrSubschemaConfig.transformedSchema
92
- : applySchemaTransforms(targetSchema, subschemaOrSubschemaConfig)),
88
+ transformedSchema: transformedSchema ??
89
+ (subschemaOrSubschemaConfig instanceof Subschema
90
+ ? subschemaOrSubschemaConfig.transformedSchema
91
+ : applySchemaTransforms(targetSchema, subschemaOrSubschemaConfig)),
93
92
  skipTypeMerging,
94
93
  };
95
94
  }
@@ -102,9 +101,9 @@ function getDelegationContext({ request, schema, fieldName, returnType, args, in
102
101
  args,
103
102
  context: request.context,
104
103
  info,
105
- returnType: (_d = returnType !== null && returnType !== void 0 ? returnType : info === null || info === void 0 ? void 0 : info.returnType) !== null && _d !== void 0 ? _d : getDelegationReturnType(subschemaOrSubschemaConfig, operation, targetFieldName),
104
+ returnType: returnType ?? info?.returnType ?? getDelegationReturnType(subschemaOrSubschemaConfig, operation, targetFieldName),
106
105
  transforms,
107
- transformedSchema: transformedSchema !== null && transformedSchema !== void 0 ? transformedSchema : subschemaOrSubschemaConfig,
106
+ transformedSchema: transformedSchema ?? subschemaOrSubschemaConfig,
108
107
  skipTypeMerging,
109
108
  };
110
109
  }
@@ -122,10 +121,10 @@ function validateRequest(delegationContext, document) {
122
121
  const GLOBAL_CONTEXT = {};
123
122
  function getExecutor(delegationContext) {
124
123
  const { subschemaConfig, targetSchema, context } = delegationContext;
125
- let executor = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.executor) || createDefaultExecutor(targetSchema);
126
- if (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batch) {
127
- const batchingOptions = subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batchingOptions;
128
- executor = getBatchingExecutor(context !== null && context !== void 0 ? context : GLOBAL_CONTEXT, executor, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.dataLoaderOptions, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.extensionsReducer);
124
+ let executor = subschemaConfig?.executor || createDefaultExecutor(targetSchema);
125
+ if (subschemaConfig?.batch) {
126
+ const batchingOptions = subschemaConfig?.batchingOptions;
127
+ executor = getBatchingExecutor(context ?? GLOBAL_CONTEXT, executor, batchingOptions?.dataLoaderOptions, batchingOptions?.extensionsReducer);
129
128
  }
130
129
  return executor;
131
130
  }
@@ -2,7 +2,6 @@ import { getNamedType, isAbstractType, isInterfaceType, isObjectType, Kind, Type
2
2
  import { getDefinedRootType, serializeInputValue, updateArgument, createVariableNameGenerator, implementsAbstractType, inspect, } from '@graphql-tools/utils';
3
3
  import { getDocumentMetadata } from './getDocumentMetadata.js';
4
4
  function finalizeGatewayDocument(targetSchema, fragments, operations) {
5
- var _a;
6
5
  let usedVariables = [];
7
6
  let usedFragments = [];
8
7
  const newOperations = [];
@@ -27,7 +26,7 @@ function finalizeGatewayDocument(targetSchema, fragments, operations) {
27
26
  usedVariables = union(usedVariables, operationOrFragmentVariables);
28
27
  newFragments = collectedNewFragments;
29
28
  fragmentSet = collectedFragmentSet;
30
- const variableDefinitions = ((_a = operation.variableDefinitions) !== null && _a !== void 0 ? _a : []).filter((variable) => operationOrFragmentVariables.indexOf(variable.variable.name.value) !== -1);
29
+ const variableDefinitions = (operation.variableDefinitions ?? []).filter((variable) => operationOrFragmentVariables.indexOf(variable.variable.name.value) !== -1);
31
30
  newOperations.push({
32
31
  kind: Kind.OPERATION_DEFINITION,
33
32
  operation: operation.operation,
@@ -53,7 +52,7 @@ export function finalizeGatewayRequest(originalRequest, delegationContext) {
53
52
  if (args) {
54
53
  const requestWithNewVariables = addVariablesToRootFields(targetSchema, operations, args);
55
54
  operations = requestWithNewVariables.newOperations;
56
- variables = Object.assign({}, variables !== null && variables !== void 0 ? variables : {}, requestWithNewVariables.newVariables);
55
+ variables = Object.assign({}, variables ?? {}, requestWithNewVariables.newVariables);
57
56
  }
58
57
  const { usedVariables, newDocument } = finalizeGatewayDocument(targetSchema, fragments, operations);
59
58
  const newVariables = {};
@@ -74,8 +73,7 @@ export function finalizeGatewayRequest(originalRequest, delegationContext) {
74
73
  function addVariablesToRootFields(targetSchema, operations, args) {
75
74
  const newVariables = Object.create(null);
76
75
  const newOperations = operations.map((operation) => {
77
- var _a, _b;
78
- const variableDefinitionMap = ((_a = operation.variableDefinitions) !== null && _a !== void 0 ? _a : []).reduce((prev, def) => ({
76
+ const variableDefinitionMap = (operation.variableDefinitions ?? []).reduce((prev, def) => ({
79
77
  ...prev,
80
78
  [def.variable.name.value]: def,
81
79
  }), {});
@@ -83,7 +81,7 @@ function addVariablesToRootFields(targetSchema, operations, args) {
83
81
  const newSelections = [];
84
82
  for (const selection of operation.selectionSet.selections) {
85
83
  if (selection.kind === Kind.FIELD) {
86
- const argumentNodes = (_b = selection.arguments) !== null && _b !== void 0 ? _b : [];
84
+ const argumentNodes = selection.arguments ?? [];
87
85
  const argumentNodeMap = argumentNodes.reduce((prev, argument) => ({
88
86
  ...prev,
89
87
  [argument.name.value]: argument,
@@ -14,8 +14,7 @@ export function annotateExternalObject(object, errors, subschema, subschemaMap)
14
14
  return object;
15
15
  }
16
16
  export function getSubschema(object, responseKey) {
17
- var _a;
18
- return (_a = object[FIELD_SUBSCHEMA_MAP_SYMBOL][responseKey]) !== null && _a !== void 0 ? _a : object[OBJECT_SUBSCHEMA_SYMBOL];
17
+ return object[FIELD_SUBSCHEMA_MAP_SYMBOL][responseKey] ?? object[OBJECT_SUBSCHEMA_SYMBOL];
19
18
  }
20
19
  export function getUnpathedErrors(object) {
21
20
  return object[UNPATHED_ERRORS_SYMBOL];
@@ -29,8 +28,7 @@ export const getActualFieldNodes = memoize1(function (fieldNode) {
29
28
  return [fieldNode];
30
29
  });
31
30
  export function mergeFields(mergedTypeInfo, object, sourceSubschema, context, info) {
32
- var _a;
33
- const delegationMaps = mergedTypeInfo.delegationPlanBuilder(info.schema, sourceSubschema, info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT, info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT, ((_a = info.fieldNodes) === null || _a === void 0 ? void 0 : _a.length)
31
+ const delegationMaps = mergedTypeInfo.delegationPlanBuilder(info.schema, sourceSubschema, info.variableValues != null && Object.keys(info.variableValues).length > 0 ? info.variableValues : EMPTY_OBJECT, info.fragments != null && Object.keys(info.fragments).length > 0 ? info.fragments : EMPTY_OBJECT, info.fieldNodes?.length
34
32
  ? info.fieldNodes.length === 1
35
33
  ? getActualFieldNodes(info.fieldNodes[0])
36
34
  : info.fieldNodes
@@ -42,7 +40,6 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
42
40
  const path = responsePathAsArray(info.path);
43
41
  const combinedFieldSubschemaMap = object[FIELD_SUBSCHEMA_MAP_SYMBOL];
44
42
  function finallyFn(source, subschema, selectionSet) {
45
- var _a;
46
43
  if (source instanceof Error || source == null) {
47
44
  const schema = subschema.transformedSchema || info.schema;
48
45
  const type = schema.getType(object.__typename);
@@ -75,7 +72,7 @@ function executeDelegationStage(mergedTypeInfo, delegationMap, object, context,
75
72
  if (sourcePropValue != null || existingPropValue == null) {
76
73
  object[responseKey] = sourcePropValue;
77
74
  }
78
- combinedFieldSubschemaMap[responseKey] = (_a = fieldSubschemaMap === null || fieldSubschemaMap === void 0 ? void 0 : fieldSubschemaMap[responseKey]) !== null && _a !== void 0 ? _a : objectSubschema;
75
+ combinedFieldSubschemaMap[responseKey] = fieldSubschemaMap?.[responseKey] ?? objectSubschema;
79
76
  }
80
77
  }
81
78
  return ValueOrPromise.all([...delegationMap.entries()].map(([subschema, selectionSet]) => new ValueOrPromise(() => {
@@ -31,7 +31,6 @@ export function prepareGatewayDocument(originalDocument, transformedSchema, retu
31
31
  visitorKeyMap);
32
32
  }
33
33
  function visitSelectionSet(node, fragmentReplacements, schema, typeInfo, possibleTypesMap, reversePossibleTypesMap, interfaceExtensionsMap, fieldNodesByType, fieldNodesByField, dynamicSelectionSetsByField) {
34
- var _a, _b;
35
34
  const newSelections = new Set();
36
35
  const maybeType = typeInfo.getParentType();
37
36
  if (maybeType != null) {
@@ -83,13 +82,13 @@ function visitSelectionSet(node, fragmentReplacements, schema, typeInfo, possibl
83
82
  }
84
83
  else {
85
84
  const fieldName = selection.name.value;
86
- const fieldNodes = (_a = fieldNodesByField[parentTypeName]) === null || _a === void 0 ? void 0 : _a[fieldName];
85
+ const fieldNodes = fieldNodesByField[parentTypeName]?.[fieldName];
87
86
  if (fieldNodes != null) {
88
87
  for (const fieldNode of fieldNodes) {
89
88
  newSelections.add(fieldNode);
90
89
  }
91
90
  }
92
- const dynamicSelectionSets = (_b = dynamicSelectionSetsByField[parentTypeName]) === null || _b === void 0 ? void 0 : _b[fieldName];
91
+ const dynamicSelectionSets = dynamicSelectionSetsByField[parentTypeName]?.[fieldName];
93
92
  if (dynamicSelectionSets != null) {
94
93
  for (const selectionSetFn of dynamicSelectionSets) {
95
94
  const selectionSet = selectionSetFn(selection);
@@ -100,7 +99,7 @@ function visitSelectionSet(node, fragmentReplacements, schema, typeInfo, possibl
100
99
  }
101
100
  }
102
101
  }
103
- if (interfaceExtensions === null || interfaceExtensions === void 0 ? void 0 : interfaceExtensions[fieldName]) {
102
+ if (interfaceExtensions?.[fieldName]) {
104
103
  interfaceExtensionFields.push(selection);
105
104
  }
106
105
  else {
@@ -149,7 +148,6 @@ function generateInlineFragment(typeName, selectionSet) {
149
148
  };
150
149
  }
151
150
  const getSchemaMetaData = memoize2((sourceSchema, targetSchema) => {
152
- var _a, _b, _c, _d;
153
151
  const typeMap = sourceSchema.getTypeMap();
154
152
  const targetTypeMap = targetSchema.getTypeMap();
155
153
  const possibleTypesMap = Object.create(null);
@@ -184,14 +182,14 @@ const getSchemaMetaData = memoize2((sourceSchema, targetSchema) => {
184
182
  }
185
183
  }
186
184
  }
187
- const stitchingInfo = (_a = sourceSchema.extensions) === null || _a === void 0 ? void 0 : _a['stitchingInfo'];
185
+ const stitchingInfo = sourceSchema.extensions?.['stitchingInfo'];
188
186
  return {
189
187
  possibleTypesMap,
190
188
  reversePossibleTypesMap: reversePossibleTypesMap(possibleTypesMap),
191
189
  interfaceExtensionsMap,
192
- fieldNodesByType: (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.fieldNodesByType) !== null && _b !== void 0 ? _b : {},
193
- fieldNodesByField: (_c = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.fieldNodesByField) !== null && _c !== void 0 ? _c : {},
194
- dynamicSelectionSetsByField: (_d = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.dynamicSelectionSetsByField) !== null && _d !== void 0 ? _d : {},
190
+ fieldNodesByType: stitchingInfo?.fieldNodesByType ?? {},
191
+ fieldNodesByField: stitchingInfo?.fieldNodesByField ?? {},
192
+ dynamicSelectionSetsByField: stitchingInfo?.dynamicSelectionSetsByField ?? {},
195
193
  };
196
194
  });
197
195
  function reversePossibleTypesMap(possibleTypesMap) {
@@ -22,7 +22,6 @@ export function resolveExternalValue(result, unpathedErrors, subschema, context,
22
22
  }
23
23
  }
24
24
  function resolveExternalObject(type, object, unpathedErrors, subschema, context, info, skipTypeMerging) {
25
- var _a;
26
25
  // if we have already resolved this object, for example, when the identical object appears twice
27
26
  // in a list, see https://github.com/ardatan/graphql-tools/issues/2304
28
27
  if (!isExternalObject(object)) {
@@ -31,7 +30,7 @@ function resolveExternalObject(type, object, unpathedErrors, subschema, context,
31
30
  if (skipTypeMerging || info == null) {
32
31
  return object;
33
32
  }
34
- const stitchingInfo = (_a = info.schema.extensions) === null || _a === void 0 ? void 0 : _a['stitchingInfo'];
33
+ const stitchingInfo = info.schema.extensions?.['stitchingInfo'];
35
34
  if (stitchingInfo == null) {
36
35
  return object;
37
36
  }
@@ -1,8 +1,7 @@
1
1
  export function isSubschemaConfig(value) {
2
- return Boolean(value === null || value === void 0 ? void 0 : value.schema);
2
+ return Boolean(value?.schema);
3
3
  }
4
4
  export function cloneSubschemaConfig(subschemaConfig) {
5
- var _a, _b;
6
5
  const newSubschemaConfig = {
7
6
  ...subschemaConfig,
8
7
  transforms: subschemaConfig.transforms != null ? [...subschemaConfig.transforms] : undefined,
@@ -10,7 +9,7 @@ export function cloneSubschemaConfig(subschemaConfig) {
10
9
  if (newSubschemaConfig.merge != null) {
11
10
  newSubschemaConfig.merge = { ...subschemaConfig.merge };
12
11
  for (const typeName in newSubschemaConfig.merge) {
13
- const mergedTypeConfig = (newSubschemaConfig.merge[typeName] = { ...((_b = (_a = subschemaConfig.merge) === null || _a === void 0 ? void 0 : _a[typeName]) !== null && _b !== void 0 ? _b : {}) });
12
+ const mergedTypeConfig = (newSubschemaConfig.merge[typeName] = { ...(subschemaConfig.merge?.[typeName] ?? {}) });
14
13
  if (mergedTypeConfig.entryPoints != null) {
15
14
  mergedTypeConfig.entryPoints = mergedTypeConfig.entryPoints.map(entryPoint => ({ ...entryPoint }));
16
15
  }
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@graphql-tools/delegate",
3
- "version": "10.0.0-rc-20230519104353-b09f3180",
3
+ "version": "10.0.0",
4
4
  "description": "A set of utils for faster development of GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-tools/batch-execute": "9.0.0-rc-20230519104353-b09f3180",
11
- "@graphql-tools/executor": "1.0.0-rc-20230519104353-b09f3180",
12
- "@graphql-tools/schema": "10.0.0-rc-20230519104353-b09f3180",
13
- "@graphql-tools/utils": "10.0.0-rc-20230519104353-b09f3180",
10
+ "@graphql-tools/batch-execute": "^9.0.0",
11
+ "@graphql-tools/executor": "^1.0.0",
12
+ "@graphql-tools/schema": "^10.0.0",
13
+ "@graphql-tools/utils": "^10.0.0",
14
14
  "dataloader": "^2.2.2",
15
15
  "tslib": "^2.5.0",
16
16
  "value-or-promise": "^1.0.12"