@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/es5/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/delegate/es5",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@ardatan/aggregate-error": "0.0.6",
|
|
11
|
-
"@graphql-tools/batch-execute": "7.0.0
|
|
12
|
-
"@graphql-tools/schema": "
|
|
13
|
-
"@graphql-tools/utils": "7.0.0
|
|
11
|
+
"@graphql-tools/batch-execute": "^7.0.0",
|
|
12
|
+
"@graphql-tools/schema": "^7.0.0",
|
|
13
|
+
"@graphql-tools/utils": "^7.0.0",
|
|
14
14
|
"dataloader": "2.0.0",
|
|
15
15
|
"is-promise": "4.0.0",
|
|
16
16
|
"tslib": "~2.0.1"
|
package/es5/types.d.ts
CHANGED
|
@@ -96,25 +96,20 @@ export interface ICreateProxyingResolverOptions {
|
|
|
96
96
|
fieldName?: string;
|
|
97
97
|
}
|
|
98
98
|
export declare type CreateProxyingResolverFn = (options: ICreateProxyingResolverOptions) => GraphQLFieldResolver<any, any>;
|
|
99
|
-
export interface
|
|
100
|
-
rootValue?: Record<string, any>;
|
|
101
|
-
executor?: Executor;
|
|
102
|
-
subscriber?: Subscriber;
|
|
103
|
-
batch?: boolean;
|
|
104
|
-
batchingOptions?: EndpointBatchingOptions<K, V, C>;
|
|
105
|
-
}
|
|
106
|
-
export interface EndpointBatchingOptions<K = any, V = any, C = K> {
|
|
99
|
+
export interface BatchingOptions<K = any, V = any, C = K> {
|
|
107
100
|
extensionsReducer?: (mergedExtensions: Record<string, any>, executionParams: ExecutionParams) => Record<string, any>;
|
|
108
101
|
dataLoaderOptions?: DataLoader.Options<K, V, C>;
|
|
109
102
|
}
|
|
110
|
-
export interface
|
|
103
|
+
export interface SubschemaConfig<K = any, V = any, C = K> {
|
|
104
|
+
schema: GraphQLSchema;
|
|
111
105
|
createProxyingResolver?: CreateProxyingResolverFn;
|
|
112
106
|
transforms?: Array<Transform>;
|
|
113
107
|
merge?: Record<string, MergedTypeConfig>;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
108
|
+
rootValue?: Record<string, any>;
|
|
109
|
+
executor?: Executor;
|
|
110
|
+
subscriber?: Subscriber;
|
|
111
|
+
batch?: boolean;
|
|
112
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
118
113
|
}
|
|
119
114
|
export interface MergedTypeConfig<K = any, V = any> {
|
|
120
115
|
selectionSet?: string;
|
package/index.cjs.js
CHANGED
|
@@ -32,7 +32,6 @@ class Subschema {
|
|
|
32
32
|
this.subscriber = config.subscriber;
|
|
33
33
|
this.batch = config.batch;
|
|
34
34
|
this.batchingOptions = config.batchingOptions;
|
|
35
|
-
this.endpoint = config.endpoint;
|
|
36
35
|
this.createProxyingResolver = config.createProxyingResolver;
|
|
37
36
|
this.transforms = (_a = config.transforms) !== null && _a !== void 0 ? _a : [];
|
|
38
37
|
this.transformedSchema = applySchemaTransforms(this.schema, config);
|
|
@@ -1583,7 +1582,7 @@ function getDelegationReturnType(targetSchema, operation, fieldName) {
|
|
|
1583
1582
|
return rootType.getFields()[fieldName].type;
|
|
1584
1583
|
}
|
|
1585
1584
|
function delegateRequest({ request, schema: subschemaOrSubschemaConfig, rootValue, info, operation, fieldName, args, returnType, context, transforms = [], transformedSchema, skipValidation, skipTypeMerging, binding, }) {
|
|
1586
|
-
var _a, _b, _c
|
|
1585
|
+
var _a, _b, _c;
|
|
1587
1586
|
let operationDefinition;
|
|
1588
1587
|
let targetOperation;
|
|
1589
1588
|
let targetFieldName;
|
|
@@ -1601,7 +1600,7 @@ function delegateRequest({ request, schema: subschemaOrSubschemaConfig, rootValu
|
|
|
1601
1600
|
else {
|
|
1602
1601
|
targetFieldName = fieldName;
|
|
1603
1602
|
}
|
|
1604
|
-
const { targetSchema, targetRootValue, subschemaConfig,
|
|
1603
|
+
const { targetSchema, targetRootValue, subschemaConfig, allTransforms } = collectTargetParameters(subschemaOrSubschemaConfig, rootValue, info, transforms);
|
|
1605
1604
|
const delegationContext = {
|
|
1606
1605
|
subschema: subschemaOrSubschemaConfig,
|
|
1607
1606
|
targetSchema,
|
|
@@ -1621,9 +1620,10 @@ function delegateRequest({ request, schema: subschemaOrSubschemaConfig, rootValu
|
|
|
1621
1620
|
validateRequest(targetSchema, processedRequest.document);
|
|
1622
1621
|
}
|
|
1623
1622
|
if (targetOperation === 'query' || targetOperation === 'mutation') {
|
|
1624
|
-
let executor = (
|
|
1625
|
-
if (
|
|
1626
|
-
|
|
1623
|
+
let executor = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.executor) || createDefaultExecutor(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
|
|
1624
|
+
if (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batch) {
|
|
1625
|
+
const batchingOptions = subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.batchingOptions;
|
|
1626
|
+
executor = batchExecute.getBatchingExecutor(context, executor, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.dataLoaderOptions, batchingOptions === null || batchingOptions === void 0 ? void 0 : batchingOptions.extensionsReducer);
|
|
1627
1627
|
}
|
|
1628
1628
|
const executionResult = executor({
|
|
1629
1629
|
...processedRequest,
|
|
@@ -1637,7 +1637,7 @@ function delegateRequest({ request, schema: subschemaOrSubschemaConfig, rootValu
|
|
|
1637
1637
|
}
|
|
1638
1638
|
return transformer.transformResult(executionResult);
|
|
1639
1639
|
}
|
|
1640
|
-
const subscriber = (
|
|
1640
|
+
const subscriber = (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.subscriber) || createDefaultSubscriber(targetSchema, (subschemaConfig === null || subschemaConfig === void 0 ? void 0 : subschemaConfig.rootValue) || targetRootValue);
|
|
1641
1641
|
return subscriber({
|
|
1642
1642
|
...processedRequest,
|
|
1643
1643
|
context,
|
|
@@ -1652,16 +1652,16 @@ function delegateRequest({ request, schema: subschemaOrSubschemaConfig, rootValu
|
|
|
1652
1652
|
return transformer.transformResult(subscriptionResult);
|
|
1653
1653
|
});
|
|
1654
1654
|
}
|
|
1655
|
+
const emptyObject = {};
|
|
1655
1656
|
function collectTargetParameters(subschema, rootValue, info, transforms = []) {
|
|
1656
|
-
var _a, _b, _c, _d;
|
|
1657
|
+
var _a, _b, _c, _d, _e;
|
|
1657
1658
|
const stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a.stitchingInfo;
|
|
1658
1659
|
const subschemaOrSubschemaConfig = (_b = stitchingInfo === null || stitchingInfo === void 0 ? void 0 : stitchingInfo.subschemaMap.get(subschema)) !== null && _b !== void 0 ? _b : subschema;
|
|
1659
1660
|
if (isSubschemaConfig(subschemaOrSubschemaConfig)) {
|
|
1660
1661
|
return {
|
|
1661
1662
|
targetSchema: subschemaOrSubschemaConfig.schema,
|
|
1662
|
-
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,
|
|
1663
|
+
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,
|
|
1663
1664
|
subschemaConfig: subschemaOrSubschemaConfig,
|
|
1664
|
-
endpoint: (_d = subschemaOrSubschemaConfig.endpoint) !== null && _d !== void 0 ? _d : subschemaOrSubschemaConfig,
|
|
1665
1665
|
allTransforms: subschemaOrSubschemaConfig.transforms != null
|
|
1666
1666
|
? subschemaOrSubschemaConfig.transforms.concat(transforms)
|
|
1667
1667
|
: transforms,
|
|
@@ -1669,7 +1669,7 @@ function collectTargetParameters(subschema, rootValue, info, transforms = []) {
|
|
|
1669
1669
|
}
|
|
1670
1670
|
return {
|
|
1671
1671
|
targetSchema: subschemaOrSubschemaConfig,
|
|
1672
|
-
targetRootValue: rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue,
|
|
1672
|
+
targetRootValue: (_e = rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue) !== null && _e !== void 0 ? _e : emptyObject,
|
|
1673
1673
|
allTransforms: transforms,
|
|
1674
1674
|
};
|
|
1675
1675
|
}
|
|
@@ -1684,7 +1684,7 @@ function validateRequest(targetSchema, document) {
|
|
|
1684
1684
|
throw error.originalError || error;
|
|
1685
1685
|
}
|
|
1686
1686
|
}
|
|
1687
|
-
|
|
1687
|
+
const createDefaultExecutor = memoize2(function (schema, rootValue) {
|
|
1688
1688
|
return (({ document, context, variables, info }) => graphql.execute({
|
|
1689
1689
|
schema,
|
|
1690
1690
|
document,
|
|
@@ -1692,7 +1692,7 @@ function createDefaultExecutor(schema, rootValue) {
|
|
|
1692
1692
|
variableValues: variables,
|
|
1693
1693
|
rootValue: rootValue !== null && rootValue !== void 0 ? rootValue : info === null || info === void 0 ? void 0 : info.rootValue,
|
|
1694
1694
|
}));
|
|
1695
|
-
}
|
|
1695
|
+
});
|
|
1696
1696
|
function createDefaultSubscriber(schema, rootValue) {
|
|
1697
1697
|
return ({ document, context, variables, info }) => graphql.subscribe({
|
|
1698
1698
|
schema,
|