@graphql-mesh/runtime 0.96.2-alpha-20230807142804-1b639bc05 → 0.96.2
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/get-mesh.js +2 -7
- package/cjs/in-context-sdk.js +14 -12
- package/esm/get-mesh.js +2 -7
- package/esm/in-context-sdk.js +16 -14
- package/package.json +3 -3
package/cjs/get-mesh.js
CHANGED
|
@@ -71,12 +71,7 @@ function wrapFetchWithPlugins(plugins) {
|
|
|
71
71
|
}
|
|
72
72
|
exports.wrapFetchWithPlugins = wrapFetchWithPlugins;
|
|
73
73
|
// Use in-context-sdk for tracing
|
|
74
|
-
function createProxyingResolverFactory(apiName, rootTypeMap
|
|
75
|
-
if (schema) {
|
|
76
|
-
return function createProxyingResolver({ operation, fieldName }) {
|
|
77
|
-
return schema.getRootType(operation).getFields()[fieldName].resolve;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
74
|
+
function createProxyingResolverFactory(apiName, rootTypeMap) {
|
|
80
75
|
return function createProxyingResolver({ operation }) {
|
|
81
76
|
const rootType = rootTypeMap.get(operation);
|
|
82
77
|
return function proxyingResolver(root, args, context, info) {
|
|
@@ -156,7 +151,7 @@ async function getMesh(options) {
|
|
|
156
151
|
handler: apiSource.handler,
|
|
157
152
|
batch: 'batch' in source ? source.batch : true,
|
|
158
153
|
merge: source.merge,
|
|
159
|
-
createProxyingResolver: createProxyingResolverFactory(apiName, rootTypeMap
|
|
154
|
+
createProxyingResolver: createProxyingResolverFactory(apiName, rootTypeMap),
|
|
160
155
|
});
|
|
161
156
|
}
|
|
162
157
|
catch (e) {
|
package/cjs/in-context-sdk.js
CHANGED
|
@@ -71,17 +71,7 @@ async function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHook
|
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
variableValues: {},
|
|
74
|
-
}, selectionSet, key, argsFromKeys, valuesFromResults, }) => {
|
|
75
|
-
if (!rawSourceSubSchemaConfig.executor &&
|
|
76
|
-
!rawSourceSubSchemaConfig.transforms?.length &&
|
|
77
|
-
!argsFromKeys &&
|
|
78
|
-
!valuesFromResults &&
|
|
79
|
-
!key) {
|
|
80
|
-
const originalSchema = rawSourceSubSchemaConfig.schema;
|
|
81
|
-
const originalRootType = originalSchema.getType(rootType.name);
|
|
82
|
-
const originalField = originalRootType.getFields()[fieldName];
|
|
83
|
-
return originalField.resolve(root, args, context, info);
|
|
84
|
-
}
|
|
74
|
+
}, selectionSet, key, argsFromKeys, valuesFromResults, autoSelectionSetWithDepth, }) => {
|
|
85
75
|
inContextSdkLogger.debug(`Called with`, {
|
|
86
76
|
args,
|
|
87
77
|
key,
|
|
@@ -109,7 +99,19 @@ async function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHook
|
|
|
109
99
|
}
|
|
110
100
|
if (selectionCount === 0) {
|
|
111
101
|
if (!selectionSet) {
|
|
112
|
-
|
|
102
|
+
if (autoSelectionSetWithDepth) {
|
|
103
|
+
const operationNode = (0, utils_2.buildOperationNodeForField)({
|
|
104
|
+
schema: transformedSchema,
|
|
105
|
+
kind: operationType,
|
|
106
|
+
depthLimit: autoSelectionSetWithDepth,
|
|
107
|
+
field: fieldName,
|
|
108
|
+
});
|
|
109
|
+
selectionSet = (0, graphql_1.print)(operationNode.selectionSet.selections[0].selectionSet);
|
|
110
|
+
console.log({ selectionSet });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw new Error(`You have to provide 'selectionSet' for context.${rawSource.name}.${rootType.name}.${fieldName}`);
|
|
114
|
+
}
|
|
113
115
|
}
|
|
114
116
|
commonDelegateOptions.info = {
|
|
115
117
|
...info,
|
package/esm/get-mesh.js
CHANGED
|
@@ -67,12 +67,7 @@ export function wrapFetchWithPlugins(plugins) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
// Use in-context-sdk for tracing
|
|
70
|
-
function createProxyingResolverFactory(apiName, rootTypeMap
|
|
71
|
-
if (schema) {
|
|
72
|
-
return function createProxyingResolver({ operation, fieldName }) {
|
|
73
|
-
return schema.getRootType(operation).getFields()[fieldName].resolve;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
70
|
+
function createProxyingResolverFactory(apiName, rootTypeMap) {
|
|
76
71
|
return function createProxyingResolver({ operation }) {
|
|
77
72
|
const rootType = rootTypeMap.get(operation);
|
|
78
73
|
return function proxyingResolver(root, args, context, info) {
|
|
@@ -152,7 +147,7 @@ export async function getMesh(options) {
|
|
|
152
147
|
handler: apiSource.handler,
|
|
153
148
|
batch: 'batch' in source ? source.batch : true,
|
|
154
149
|
merge: source.merge,
|
|
155
|
-
createProxyingResolver: createProxyingResolverFactory(apiName, rootTypeMap
|
|
150
|
+
createProxyingResolver: createProxyingResolverFactory(apiName, rootTypeMap),
|
|
156
151
|
});
|
|
157
152
|
}
|
|
158
153
|
catch (e) {
|
package/esm/in-context-sdk.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getNamedType, isLeafType, Kind, } from 'graphql';
|
|
1
|
+
import { getNamedType, isLeafType, Kind, print, } from 'graphql';
|
|
2
2
|
import { parseWithCache } from '@graphql-mesh/utils';
|
|
3
3
|
import { batchDelegateToSchema } from '@graphql-tools/batch-delegate';
|
|
4
4
|
import { delegateToSchema, } from '@graphql-tools/delegate';
|
|
5
|
-
import { isDocumentNode, memoize1 } from '@graphql-tools/utils';
|
|
5
|
+
import { buildOperationNodeForField, isDocumentNode, memoize1 } from '@graphql-tools/utils';
|
|
6
6
|
import { WrapQuery } from '@graphql-tools/wrap';
|
|
7
7
|
import { MESH_API_CONTEXT_SYMBOL } from './constants.js';
|
|
8
8
|
export async function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHooks) {
|
|
@@ -68,17 +68,7 @@ export async function getInContextSDK(unifiedSchema, rawSources, logger, onDeleg
|
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
70
|
variableValues: {},
|
|
71
|
-
}, selectionSet, key, argsFromKeys, valuesFromResults, }) => {
|
|
72
|
-
if (!rawSourceSubSchemaConfig.executor &&
|
|
73
|
-
!rawSourceSubSchemaConfig.transforms?.length &&
|
|
74
|
-
!argsFromKeys &&
|
|
75
|
-
!valuesFromResults &&
|
|
76
|
-
!key) {
|
|
77
|
-
const originalSchema = rawSourceSubSchemaConfig.schema;
|
|
78
|
-
const originalRootType = originalSchema.getType(rootType.name);
|
|
79
|
-
const originalField = originalRootType.getFields()[fieldName];
|
|
80
|
-
return originalField.resolve(root, args, context, info);
|
|
81
|
-
}
|
|
71
|
+
}, selectionSet, key, argsFromKeys, valuesFromResults, autoSelectionSetWithDepth, }) => {
|
|
82
72
|
inContextSdkLogger.debug(`Called with`, {
|
|
83
73
|
args,
|
|
84
74
|
key,
|
|
@@ -106,7 +96,19 @@ export async function getInContextSDK(unifiedSchema, rawSources, logger, onDeleg
|
|
|
106
96
|
}
|
|
107
97
|
if (selectionCount === 0) {
|
|
108
98
|
if (!selectionSet) {
|
|
109
|
-
|
|
99
|
+
if (autoSelectionSetWithDepth) {
|
|
100
|
+
const operationNode = buildOperationNodeForField({
|
|
101
|
+
schema: transformedSchema,
|
|
102
|
+
kind: operationType,
|
|
103
|
+
depthLimit: autoSelectionSetWithDepth,
|
|
104
|
+
field: fieldName,
|
|
105
|
+
});
|
|
106
|
+
selectionSet = print(operationNode.selectionSet.selections[0].selectionSet);
|
|
107
|
+
console.log({ selectionSet });
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw new Error(`You have to provide 'selectionSet' for context.${rawSource.name}.${rootType.name}.${fieldName}`);
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
commonDelegateOptions.info = {
|
|
112
114
|
...info,
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/runtime",
|
|
3
|
-
"version": "0.96.2
|
|
3
|
+
"version": "0.96.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@graphql-mesh/cross-helpers": "^0.4.0",
|
|
7
|
-
"@graphql-mesh/types": "^0.95.
|
|
8
|
-
"@graphql-mesh/utils": "^0.95.
|
|
7
|
+
"@graphql-mesh/types": "^0.95.2",
|
|
8
|
+
"@graphql-mesh/utils": "^0.95.2",
|
|
9
9
|
"@graphql-tools/utils": "^9.2.1 || ^10.0.0",
|
|
10
10
|
"graphql": "*",
|
|
11
11
|
"tslib": "^2.4.0"
|