@graphql-tools/delegate 7.0.0-alpha-624d205a.0 → 7.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/es5/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cloneSchema, serializeInputValue, updateArgument, collectFields, relocatedError, mergeDeep, getResponseKeyFromInfo, implementsAbstractType, mapAsyncIterator } from '@graphql-tools/utils/es5';
2
2
  import { __assign, __spread, __values, __read } from 'tslib';
3
- import { Kind, typeFromAST, GraphQLError, responsePathAsArray, getNamedType, getNullableType, isLeafType, isCompositeType, isListType, isAbstractType, locatedError, defaultFieldResolver, TypeInfo, visit, visitWithTypeInfo, print, isInterfaceType, isObjectType, TypeNameMetaFieldDef, getOperationAST, execute, subscribe, validate } from 'graphql';
3
+ import { Kind, typeFromAST, GraphQLError, responsePathAsArray, getNamedType, getNullableType, isLeafType, isCompositeType, isListType, isAbstractType, locatedError, defaultFieldResolver, TypeInfo, visit, visitWithTypeInfo, print, isInterfaceType, isObjectType, TypeNameMetaFieldDef, getOperationAST, subscribe, validate, execute } from 'graphql';
4
4
  import isPromise from 'is-promise';
5
5
  import AggregateError$1 from '@ardatan/aggregate-error';
6
6
  import { getBatchingExecutor } from '@graphql-tools/batch-execute/es5';
@@ -29,7 +29,6 @@ var Subschema = /** @class */ (function () {
29
29
  this.subscriber = config.subscriber;
30
30
  this.batch = config.batch;
31
31
  this.batchingOptions = config.batchingOptions;
32
- this.endpoint = config.endpoint;
33
32
  this.createProxyingResolver = config.createProxyingResolver;
34
33
  this.transforms = (_a = config.transforms) !== null && _a !== void 0 ? _a : [];
35
34
  this.transformedSchema = applySchemaTransforms(this.schema, config);
@@ -1594,8 +1593,8 @@ function getDelegationReturnType(targetSchema, operation, fieldName) {
1594
1593
  return rootType.getFields()[fieldName].type;
1595
1594
  }
1596
1595
  function delegateRequest(_a) {
1597
- var _b, _c, _d, _e, _f;
1598
- var request = _a.request, subschemaOrSubschemaConfig = _a.schema, rootValue = _a.rootValue, info = _a.info, operation = _a.operation, fieldName = _a.fieldName, args = _a.args, returnType = _a.returnType, context = _a.context, _g = _a.transforms, transforms = _g === void 0 ? [] : _g, transformedSchema = _a.transformedSchema, skipValidation = _a.skipValidation, skipTypeMerging = _a.skipTypeMerging, binding = _a.binding;
1596
+ var _b, _c, _d;
1597
+ var request = _a.request, subschemaOrSubschemaConfig = _a.schema, rootValue = _a.rootValue, info = _a.info, operation = _a.operation, fieldName = _a.fieldName, args = _a.args, returnType = _a.returnType, context = _a.context, _e = _a.transforms, transforms = _e === void 0 ? [] : _e, transformedSchema = _a.transformedSchema, skipValidation = _a.skipValidation, skipTypeMerging = _a.skipTypeMerging, binding = _a.binding;
1599
1598
  var operationDefinition;
1600
1599
  var targetOperation;
1601
1600
  var targetFieldName;
@@ -1613,7 +1612,7 @@ function delegateRequest(_a) {
1613
1612
  else {
1614
1613
  targetFieldName = fieldName;
1615
1614
  }
1616
- var _h = collectTargetParameters(subschemaOrSubschemaConfig, rootValue, info, transforms), targetSchema = _h.targetSchema, targetRootValue = _h.targetRootValue, subschemaConfig = _h.subschemaConfig, endpoint = _h.endpoint, allTransforms = _h.allTransforms;
1615
+ var _f = collectTargetParameters(subschemaOrSubschemaConfig, rootValue, info, transforms), targetSchema = _f.targetSchema, targetRootValue = _f.targetRootValue, subschemaConfig = _f.subschemaConfig, allTransforms = _f.allTransforms;
1617
1616
  var delegationContext = {
1618
1617
  subschema: subschemaOrSubschemaConfig,
1619
1618
  targetSchema: targetSchema,
@@ -1633,9 +1632,10 @@ function delegateRequest(_a) {
1633
1632
  validateRequest(targetSchema, processedRequest.document);
1634
1633
  }
1635
1634
  if (targetOperation === 'query' || targetOperation === 'mutation') {
1636
- var executor = (endpoint === null || endpoint === void 0 ? void 0 : endpoint.executor) || createDefaultExecutor(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
1637
- if (endpoint === null || endpoint === void 0 ? void 0 : endpoint.batch) {
1638
- executor = getBatchingExecutor(context, executor, (_e = endpoint === null || endpoint === void 0 ? void 0 : endpoint.batchingOptions) === null || _e === void 0 ? void 0 : _e.dataLoaderOptions, (_f = endpoint === null || endpoint === void 0 ? void 0 : endpoint.batchingOptions) === null || _f === void 0 ? void 0 : _f.extensionsReducer);
1635
+ var executor = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.executor) || createDefaultExecutor(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
1636
+ if (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batch) {
1637
+ var batchingOptions = subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batchingOptions;
1638
+ executor = getBatchingExecutor(context, executor, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.dataLoaderOptions, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.extensionsReducer);
1639
1639
  }
1640
1640
  var executionResult = executor(__assign(__assign({}, processedRequest), { context: context,
1641
1641
  info: info }));
@@ -1646,7 +1646,7 @@ function delegateRequest(_a) {
1646
1646
  }
1647
1647
  return transformer.transformResult(executionResult);
1648
1648
  }
1649
- var subscriber = (endpoint === null || endpoint === void 0 ? void 0 : endpoint.subscriber) || createDefaultSubscriber(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
1649
+ var subscriber = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.subscriber) || createDefaultSubscriber(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
1650
1650
  return subscriber(__assign(__assign({}, processedRequest), { context: context,
1651
1651
  info: info })).then(function (subscriptionResult) {
1652
1652
  if (Symbol.asyncIterator in subscriptionResult) {
@@ -1661,17 +1661,17 @@ function delegateRequest(_a) {
1661
1661
  return transformer.transformResult(subscriptionResult);
1662
1662
  });
1663
1663
  }
1664
+ var emptyObject = {};
1664
1665
  function collectTargetParameters(subschema, rootValue, info, transforms) {
1665
- var _a, _b, _c, _d;
1666
+ var _a, _b, _c, _d, _e;
1666
1667
  if (transforms === void 0) { transforms = []; }
1667
1668
  var stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a.stitchingInfo;
1668
1669
  var subschemaOrSubschemaConfig = (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.subschemaMap.get(subschema)) !== null && _b !== void 0 ? _b : subschema;
1669
1670
  if (isSubschemaConfig(subschemaOrSubschemaConfig)) {
1670
1671
  return {
1671
1672
  targetSchema: subschemaOrSubschemaConfig.schema,
1672
- targetRootValue: (_c = rootValue !== null && rootValue !== void 0 ? rootValue : subschemaOrSubschemaConfig === null || subschemaOrSubschemaConfig === void 0 ? void 0 : subschemaOrSubschemaConfig.rootValue) !== null && _c !== void 0 ? _c : info === null || info === void 0 ? void 0 : info.rootValue,
1673
+ targetRootValue: (_d = (_c = rootValue !== null && rootValue !== void 0 ? rootValue : subschemaOrSubschemaConfig === null || subschemaOrSubschemaConfig === void 0 ? void 0 : subschemaOrSubschemaConfig.rootValue) !== null && _c !== void 0 ? _c : info === null || info === void 0 ? void 0 : info.rootValue) !== null && _d !== void 0 ? _d : emptyObject,
1673
1674
  subschemaConfig: subschemaOrSubschemaConfig,
1674
- endpoint: (_d = subschemaOrSubschemaConfig.endpoint) !== null && _d !== void 0 ? _d : subschemaOrSubschemaConfig,
1675
1675
  allTransforms: subschemaOrSubschemaConfig.transforms != null
1676
1676
  ? subschemaOrSubschemaConfig.transforms.concat(transforms)
1677
1677
  : transforms,
@@ -1679,7 +1679,7 @@ function collectTargetParameters(subschema, rootValue, info, transforms) {
1679
1679
  }
1680
1680
  return {
1681
1681
  targetSchema: subschemaOrSubschemaConfig,
1682
- targetRootValue: rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue,
1682
+ targetRootValue: (_e = rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue) !== null && _e !== void 0 ? _e : emptyObject,
1683
1683
  allTransforms: transforms,
1684
1684
  };
1685
1685
  }
@@ -1694,7 +1694,7 @@ function validateRequest(targetSchema, document) {
1694
1694
  throw error.originalError || error;
1695
1695
  }
1696
1696
  }
1697
- function createDefaultExecutor(schema, rootValue) {
1697
+ var createDefaultExecutor = memoize2(function (schema, rootValue) {
1698
1698
  return (function (_a) {
1699
1699
  var document = _a.document, context = _a.context, variables = _a.variables, info = _a.info;
1700
1700
  return execute({
@@ -1705,7 +1705,7 @@ function createDefaultExecutor(schema, rootValue) {
1705
1705
  rootValue: rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue,
1706
1706
  });
1707
1707
  });
1708
- }
1708
+ });
1709
1709
  function createDefaultSubscriber(schema, rootValue) {
1710
1710
  return function (_a) {
1711
1711
  var document = _a.document, context = _a.context, variables = _a.variables, info = _a.info;