@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/Subschema.d.ts +2 -3
- package/es5/Subschema.d.ts +2 -3
- package/es5/index.cjs.js +14 -14
- package/es5/index.cjs.js.map +1 -1
- package/es5/index.esm.js +15 -15
- package/es5/index.esm.js.map +1 -1
- package/es5/package.json +4 -4
- package/es5/types.d.ts +8 -13
- package/index.cjs.js +13 -13
- package/index.cjs.js.map +1 -1
- package/index.esm.js +14 -14
- package/index.esm.js.map +1 -1
- package/package.json +4 -4
- package/types.d.ts +8 -13
package/Subschema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, Subscriber, Executor,
|
|
2
|
+
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, Subscriber, Executor, BatchingOptions } from './types';
|
|
3
3
|
export declare function isSubschema(value: any): value is Subschema;
|
|
4
4
|
interface ISubschema extends SubschemaConfig {
|
|
5
5
|
transformedSchema: GraphQLSchema;
|
|
@@ -10,8 +10,7 @@ export declare class Subschema<K = any, V = any, C = K> implements ISubschema {
|
|
|
10
10
|
executor?: Executor;
|
|
11
11
|
subscriber?: Subscriber;
|
|
12
12
|
batch?: boolean;
|
|
13
|
-
batchingOptions?:
|
|
14
|
-
endpoint?: Endpoint;
|
|
13
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
15
14
|
createProxyingResolver?: CreateProxyingResolverFn;
|
|
16
15
|
transforms: Array<Transform>;
|
|
17
16
|
transformedSchema: GraphQLSchema;
|
package/es5/Subschema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, Subscriber, Executor,
|
|
2
|
+
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, Subscriber, Executor, BatchingOptions } from './types';
|
|
3
3
|
export declare function isSubschema(value: any): value is Subschema;
|
|
4
4
|
interface ISubschema extends SubschemaConfig {
|
|
5
5
|
transformedSchema: GraphQLSchema;
|
|
@@ -10,8 +10,7 @@ export declare class Subschema<K = any, V = any, C = K> implements ISubschema {
|
|
|
10
10
|
executor?: Executor;
|
|
11
11
|
subscriber?: Subscriber;
|
|
12
12
|
batch?: boolean;
|
|
13
|
-
batchingOptions?:
|
|
14
|
-
endpoint?: Endpoint;
|
|
13
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
15
14
|
createProxyingResolver?: CreateProxyingResolverFn;
|
|
16
15
|
transforms: Array<Transform>;
|
|
17
16
|
transformedSchema: GraphQLSchema;
|
package/es5/index.cjs.js
CHANGED
|
@@ -35,7 +35,6 @@ var Subschema = /** @class */ (function () {
|
|
|
35
35
|
this.subscriber = config.subscriber;
|
|
36
36
|
this.batch = config.batch;
|
|
37
37
|
this.batchingOptions = config.batchingOptions;
|
|
38
|
-
this.endpoint = config.endpoint;
|
|
39
38
|
this.createProxyingResolver = config.createProxyingResolver;
|
|
40
39
|
this.transforms = (_a = config.transforms) !== null && _a !== void 0 ? _a : [];
|
|
41
40
|
this.transformedSchema = applySchemaTransforms(this.schema, config);
|
|
@@ -1600,8 +1599,8 @@ function getDelegationReturnType(targetSchema, operation, fieldName) {
|
|
|
1600
1599
|
return rootType.getFields()[fieldName].type;
|
|
1601
1600
|
}
|
|
1602
1601
|
function delegateRequest(_a) {
|
|
1603
|
-
var _b, _c, _d
|
|
1604
|
-
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,
|
|
1602
|
+
var _b, _c, _d;
|
|
1603
|
+
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;
|
|
1605
1604
|
var operationDefinition;
|
|
1606
1605
|
var targetOperation;
|
|
1607
1606
|
var targetFieldName;
|
|
@@ -1619,7 +1618,7 @@ function delegateRequest(_a) {
|
|
|
1619
1618
|
else {
|
|
1620
1619
|
targetFieldName = fieldName;
|
|
1621
1620
|
}
|
|
1622
|
-
var
|
|
1621
|
+
var _f = collectTargetParameters(subschemaOrSubschemaConfig, rootValue, info, transforms), targetSchema = _f.targetSchema, targetRootValue = _f.targetRootValue, subschemaConfig = _f.subschemaConfig, allTransforms = _f.allTransforms;
|
|
1623
1622
|
var delegationContext = {
|
|
1624
1623
|
subschema: subschemaOrSubschemaConfig,
|
|
1625
1624
|
targetSchema: targetSchema,
|
|
@@ -1639,9 +1638,10 @@ function delegateRequest(_a) {
|
|
|
1639
1638
|
validateRequest(targetSchema, processedRequest.document);
|
|
1640
1639
|
}
|
|
1641
1640
|
if (targetOperation === 'query' || targetOperation === 'mutation') {
|
|
1642
|
-
var executor = (
|
|
1643
|
-
if (
|
|
1644
|
-
|
|
1641
|
+
var executor = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.executor) || createDefaultExecutor(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
|
|
1642
|
+
if (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batch) {
|
|
1643
|
+
var batchingOptions = subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batchingOptions;
|
|
1644
|
+
executor = batchExecute.getBatchingExecutor(context, executor, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.dataLoaderOptions, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.extensionsReducer);
|
|
1645
1645
|
}
|
|
1646
1646
|
var executionResult = executor(tslib.__assign(tslib.__assign({}, processedRequest), { context: context,
|
|
1647
1647
|
info: info }));
|
|
@@ -1652,7 +1652,7 @@ function delegateRequest(_a) {
|
|
|
1652
1652
|
}
|
|
1653
1653
|
return transformer.transformResult(executionResult);
|
|
1654
1654
|
}
|
|
1655
|
-
var subscriber = (
|
|
1655
|
+
var subscriber = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.subscriber) || createDefaultSubscriber(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
|
|
1656
1656
|
return subscriber(tslib.__assign(tslib.__assign({}, processedRequest), { context: context,
|
|
1657
1657
|
info: info })).then(function (subscriptionResult) {
|
|
1658
1658
|
if (Symbol.asyncIterator in subscriptionResult) {
|
|
@@ -1667,17 +1667,17 @@ function delegateRequest(_a) {
|
|
|
1667
1667
|
return transformer.transformResult(subscriptionResult);
|
|
1668
1668
|
});
|
|
1669
1669
|
}
|
|
1670
|
+
var emptyObject = {};
|
|
1670
1671
|
function collectTargetParameters(subschema, rootValue, info, transforms) {
|
|
1671
|
-
var _a, _b, _c, _d;
|
|
1672
|
+
var _a, _b, _c, _d, _e;
|
|
1672
1673
|
if (transforms === void 0) { transforms = []; }
|
|
1673
1674
|
var stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a.stitchingInfo;
|
|
1674
1675
|
var subschemaOrSubschemaConfig = (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.subschemaMap.get(subschema)) !== null && _b !== void 0 ? _b : subschema;
|
|
1675
1676
|
if (isSubschemaConfig(subschemaOrSubschemaConfig)) {
|
|
1676
1677
|
return {
|
|
1677
1678
|
targetSchema: subschemaOrSubschemaConfig.schema,
|
|
1678
|
-
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,
|
|
1679
|
+
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,
|
|
1679
1680
|
subschemaConfig: subschemaOrSubschemaConfig,
|
|
1680
|
-
endpoint: (_d = subschemaOrSubschemaConfig.endpoint) !== null && _d !== void 0 ? _d : subschemaOrSubschemaConfig,
|
|
1681
1681
|
allTransforms: subschemaOrSubschemaConfig.transforms != null
|
|
1682
1682
|
? subschemaOrSubschemaConfig.transforms.concat(transforms)
|
|
1683
1683
|
: transforms,
|
|
@@ -1685,7 +1685,7 @@ function collectTargetParameters(subschema, rootValue, info, transforms) {
|
|
|
1685
1685
|
}
|
|
1686
1686
|
return {
|
|
1687
1687
|
targetSchema: subschemaOrSubschemaConfig,
|
|
1688
|
-
targetRootValue: rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue,
|
|
1688
|
+
targetRootValue: (_e = rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue) !== null && _e !== void 0 ? _e : emptyObject,
|
|
1689
1689
|
allTransforms: transforms,
|
|
1690
1690
|
};
|
|
1691
1691
|
}
|
|
@@ -1700,7 +1700,7 @@ function validateRequest(targetSchema, document) {
|
|
|
1700
1700
|
throw error.originalError || error;
|
|
1701
1701
|
}
|
|
1702
1702
|
}
|
|
1703
|
-
|
|
1703
|
+
var createDefaultExecutor = memoize2(function (schema, rootValue) {
|
|
1704
1704
|
return (function (_a) {
|
|
1705
1705
|
var document = _a.document, context = _a.context, variables = _a.variables, info = _a.info;
|
|
1706
1706
|
return graphql.execute({
|
|
@@ -1711,7 +1711,7 @@ function createDefaultExecutor(schema, rootValue) {
|
|
|
1711
1711
|
rootValue: rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue,
|
|
1712
1712
|
});
|
|
1713
1713
|
});
|
|
1714
|
-
}
|
|
1714
|
+
});
|
|
1715
1715
|
function createDefaultSubscriber(schema, rootValue) {
|
|
1716
1716
|
return function (_a) {
|
|
1717
1717
|
var document = _a.document, context = _a.context, variables = _a.variables, info = _a.info;
|