@graphql-mesh/runtime 0.96.2-alpha-20230807141236-b71751378 → 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 -10
- package/esm/get-mesh.js +2 -7
- package/esm/in-context-sdk.js +16 -12
- 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,7 +71,7 @@ async function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHook
|
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
variableValues: {},
|
|
74
|
-
}, selectionSet, key, argsFromKeys, valuesFromResults, }) => {
|
|
74
|
+
}, selectionSet, key, argsFromKeys, valuesFromResults, autoSelectionSetWithDepth, }) => {
|
|
75
75
|
inContextSdkLogger.debug(`Called with`, {
|
|
76
76
|
args,
|
|
77
77
|
key,
|
|
@@ -99,7 +99,19 @@ async function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHook
|
|
|
99
99
|
}
|
|
100
100
|
if (selectionCount === 0) {
|
|
101
101
|
if (!selectionSet) {
|
|
102
|
-
|
|
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
|
+
}
|
|
103
115
|
}
|
|
104
116
|
commonDelegateOptions.info = {
|
|
105
117
|
...info,
|
|
@@ -165,14 +177,6 @@ async function getInContextSDK(unifiedSchema, rawSources, logger, onDelegateHook
|
|
|
165
177
|
...commonDelegateOptions,
|
|
166
178
|
args,
|
|
167
179
|
};
|
|
168
|
-
if (!rawSourceSubSchemaConfig.executor &&
|
|
169
|
-
!regularDelegateOptions.transforms?.length &&
|
|
170
|
-
!rawSourceSubSchemaConfig.transforms?.length) {
|
|
171
|
-
const originalSchema = rawSourceSubSchemaConfig.schema;
|
|
172
|
-
const originalRootType = originalSchema.getType(rootType.name);
|
|
173
|
-
const originalField = originalRootType.getFields()[fieldName];
|
|
174
|
-
return originalField.resolve(root, args, context, info);
|
|
175
|
-
}
|
|
176
180
|
if (selectionSet) {
|
|
177
181
|
const selectionSetFactory = normalizeSelectionSetParamOrFactory(selectionSet);
|
|
178
182
|
const path = [fieldName];
|
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,7 +68,7 @@ export async function getInContextSDK(unifiedSchema, rawSources, logger, onDeleg
|
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
70
|
variableValues: {},
|
|
71
|
-
}, selectionSet, key, argsFromKeys, valuesFromResults, }) => {
|
|
71
|
+
}, selectionSet, key, argsFromKeys, valuesFromResults, autoSelectionSetWithDepth, }) => {
|
|
72
72
|
inContextSdkLogger.debug(`Called with`, {
|
|
73
73
|
args,
|
|
74
74
|
key,
|
|
@@ -96,7 +96,19 @@ export async function getInContextSDK(unifiedSchema, rawSources, logger, onDeleg
|
|
|
96
96
|
}
|
|
97
97
|
if (selectionCount === 0) {
|
|
98
98
|
if (!selectionSet) {
|
|
99
|
-
|
|
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
|
+
}
|
|
100
112
|
}
|
|
101
113
|
commonDelegateOptions.info = {
|
|
102
114
|
...info,
|
|
@@ -162,14 +174,6 @@ export async function getInContextSDK(unifiedSchema, rawSources, logger, onDeleg
|
|
|
162
174
|
...commonDelegateOptions,
|
|
163
175
|
args,
|
|
164
176
|
};
|
|
165
|
-
if (!rawSourceSubSchemaConfig.executor &&
|
|
166
|
-
!regularDelegateOptions.transforms?.length &&
|
|
167
|
-
!rawSourceSubSchemaConfig.transforms?.length) {
|
|
168
|
-
const originalSchema = rawSourceSubSchemaConfig.schema;
|
|
169
|
-
const originalRootType = originalSchema.getType(rootType.name);
|
|
170
|
-
const originalField = originalRootType.getFields()[fieldName];
|
|
171
|
-
return originalField.resolve(root, args, context, info);
|
|
172
|
-
}
|
|
173
177
|
if (selectionSet) {
|
|
174
178
|
const selectionSetFactory = normalizeSelectionSetParamOrFactory(selectionSet);
|
|
175
179
|
const path = [fieldName];
|
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"
|