@graphql-mesh/runtime 0.96.4 → 0.96.5-alpha-20230913212228-71af2a353
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 +10 -4
- package/cjs/useSubschema.js +17 -1
- package/esm/get-mesh.js +11 -5
- package/esm/useSubschema.js +18 -2
- package/package.json +4 -2
package/cjs/get-mesh.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.getMesh = exports.wrapFetchWithPlugins = void 0;
|
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
5
|
const core_1 = require("@envelop/core");
|
|
6
6
|
const extended_validation_1 = require("@envelop/extended-validation");
|
|
7
|
+
const graphql_jit_1 = require("@envelop/graphql-jit");
|
|
7
8
|
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
8
9
|
const utils_1 = require("@graphql-mesh/utils");
|
|
9
10
|
const delegate_1 = require("@graphql-tools/delegate");
|
|
@@ -188,14 +189,19 @@ async function getMesh(options) {
|
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
let inContextSDK;
|
|
191
|
-
|
|
192
|
+
let subschema;
|
|
193
|
+
if (unifiedSubschema.executor != null || unifiedSubschema.transforms?.length) {
|
|
194
|
+
subschema = new delegate_1.Subschema(unifiedSubschema);
|
|
195
|
+
}
|
|
192
196
|
const plugins = [
|
|
193
197
|
(0, core_1.useEngine)({
|
|
194
198
|
validate: graphql_1.validate,
|
|
195
199
|
parse: utils_1.parseWithCache,
|
|
196
200
|
specifiedRules: graphql_1.specifiedRules,
|
|
197
201
|
}),
|
|
198
|
-
(
|
|
202
|
+
...(subschema
|
|
203
|
+
? [(0, useSubschema_js_1.useSubschema)(new delegate_1.Subschema(unifiedSubschema))]
|
|
204
|
+
: [(0, core_1.useSchema)(unifiedSubschema.schema), (0, graphql_jit_1.useGraphQlJit)()]),
|
|
199
205
|
(0, core_1.useExtendContext)(() => {
|
|
200
206
|
if (!inContextSDK) {
|
|
201
207
|
const onDelegateHooks = [];
|
|
@@ -204,7 +210,7 @@ async function getMesh(options) {
|
|
|
204
210
|
onDelegateHooks.push(plugin.onDelegate);
|
|
205
211
|
}
|
|
206
212
|
}
|
|
207
|
-
inContextSDK = (0, in_context_sdk_js_1.getInContextSDK)(subschema.transformedSchema, rawSources, logger, onDelegateHooks);
|
|
213
|
+
inContextSDK = (0, in_context_sdk_js_1.getInContextSDK)(subschema ? subschema.transformedSchema : unifiedSubschema.schema, rawSources, logger, onDelegateHooks);
|
|
208
214
|
}
|
|
209
215
|
return inContextSDK;
|
|
210
216
|
}),
|
|
@@ -258,7 +264,7 @@ async function getMesh(options) {
|
|
|
258
264
|
}
|
|
259
265
|
return {
|
|
260
266
|
get schema() {
|
|
261
|
-
return subschema.transformedSchema;
|
|
267
|
+
return subschema ? subschema.transformedSchema : unifiedSubschema.schema;
|
|
262
268
|
},
|
|
263
269
|
rawSources,
|
|
264
270
|
cache,
|
package/cjs/useSubschema.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useSubschema = void 0;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
+
const graphql_jit_1 = require("graphql-jit");
|
|
5
6
|
const core_1 = require("@envelop/core");
|
|
6
7
|
const utils_1 = require("@graphql-mesh/utils");
|
|
7
8
|
const delegate_1 = require("@graphql-tools/delegate");
|
|
@@ -28,6 +29,7 @@ function getIntrospectionOperationType(operationAST) {
|
|
|
28
29
|
return introspectionQueryType;
|
|
29
30
|
}
|
|
30
31
|
function getExecuteFn(subschema) {
|
|
32
|
+
const compiledQueryCache = new WeakMap();
|
|
31
33
|
return function subschemaExecute(args) {
|
|
32
34
|
const originalRequest = {
|
|
33
35
|
document: args.document,
|
|
@@ -67,7 +69,21 @@ function getExecuteFn(subschema) {
|
|
|
67
69
|
};
|
|
68
70
|
let executor = subschema.executor;
|
|
69
71
|
if (executor == null) {
|
|
70
|
-
executor =
|
|
72
|
+
executor = function subschemaExecutor(request) {
|
|
73
|
+
let compiledQuery = compiledQueryCache.get(args.document);
|
|
74
|
+
if (!compiledQuery) {
|
|
75
|
+
const compilationResult = (0, graphql_jit_1.compileQuery)(subschema.schema, request.document, args.operationName ?? undefined);
|
|
76
|
+
if (!(0, graphql_jit_1.isCompiledQuery)(compilationResult)) {
|
|
77
|
+
return compilationResult;
|
|
78
|
+
}
|
|
79
|
+
compiledQuery = compilationResult;
|
|
80
|
+
compiledQueryCache.set(args.document, compiledQuery);
|
|
81
|
+
}
|
|
82
|
+
if (operationAST.operation === 'subscription') {
|
|
83
|
+
return compiledQuery.subscribe(request.rootValue, request.context, request.variables);
|
|
84
|
+
}
|
|
85
|
+
return compiledQuery.query(request.rootValue, request.context, request.variables);
|
|
86
|
+
};
|
|
71
87
|
}
|
|
72
88
|
/*
|
|
73
89
|
if (subschema.batch) {
|
package/esm/get-mesh.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getOperationAST, specifiedRules, validate, } from 'graphql';
|
|
2
|
-
import { envelop, useEngine, useExtendContext } from '@envelop/core';
|
|
2
|
+
import { envelop, useEngine, useExtendContext, useSchema } from '@envelop/core';
|
|
3
3
|
import { OneOfInputObjectsRule, useExtendedValidation } from '@envelop/extended-validation';
|
|
4
|
+
import { useGraphQlJit } from '@envelop/graphql-jit';
|
|
4
5
|
import { process } from '@graphql-mesh/cross-helpers';
|
|
5
6
|
import { applySchemaTransforms, DefaultLogger, getHeadersObj, groupTransforms, parseWithCache, PubSub, } from '@graphql-mesh/utils';
|
|
6
7
|
import { Subschema } from '@graphql-tools/delegate';
|
|
@@ -184,14 +185,19 @@ export async function getMesh(options) {
|
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
let inContextSDK;
|
|
187
|
-
|
|
188
|
+
let subschema;
|
|
189
|
+
if (unifiedSubschema.executor != null || unifiedSubschema.transforms?.length) {
|
|
190
|
+
subschema = new Subschema(unifiedSubschema);
|
|
191
|
+
}
|
|
188
192
|
const plugins = [
|
|
189
193
|
useEngine({
|
|
190
194
|
validate,
|
|
191
195
|
parse: parseWithCache,
|
|
192
196
|
specifiedRules,
|
|
193
197
|
}),
|
|
194
|
-
|
|
198
|
+
...(subschema
|
|
199
|
+
? [useSubschema(new Subschema(unifiedSubschema))]
|
|
200
|
+
: [useSchema(unifiedSubschema.schema), useGraphQlJit()]),
|
|
195
201
|
useExtendContext(() => {
|
|
196
202
|
if (!inContextSDK) {
|
|
197
203
|
const onDelegateHooks = [];
|
|
@@ -200,7 +206,7 @@ export async function getMesh(options) {
|
|
|
200
206
|
onDelegateHooks.push(plugin.onDelegate);
|
|
201
207
|
}
|
|
202
208
|
}
|
|
203
|
-
inContextSDK = getInContextSDK(subschema.transformedSchema, rawSources, logger, onDelegateHooks);
|
|
209
|
+
inContextSDK = getInContextSDK(subschema ? subschema.transformedSchema : unifiedSubschema.schema, rawSources, logger, onDelegateHooks);
|
|
204
210
|
}
|
|
205
211
|
return inContextSDK;
|
|
206
212
|
}),
|
|
@@ -254,7 +260,7 @@ export async function getMesh(options) {
|
|
|
254
260
|
}
|
|
255
261
|
return {
|
|
256
262
|
get schema() {
|
|
257
|
-
return subschema.transformedSchema;
|
|
263
|
+
return subschema ? subschema.transformedSchema : unifiedSubschema.schema;
|
|
258
264
|
},
|
|
259
265
|
rawSources,
|
|
260
266
|
cache,
|
package/esm/useSubschema.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BREAK, execute, visit } from 'graphql';
|
|
2
|
+
import { compileQuery, isCompiledQuery } from 'graphql-jit';
|
|
2
3
|
import { mapAsyncIterator } from '@envelop/core';
|
|
3
4
|
import { applyRequestTransforms, applyResultTransforms } from '@graphql-mesh/utils';
|
|
4
|
-
import { applySchemaTransforms
|
|
5
|
+
import { applySchemaTransforms } from '@graphql-tools/delegate';
|
|
5
6
|
import { getDefinedRootType, getOperationASTFromRequest, isAsyncIterable, isPromise, printSchemaWithDirectives, } from '@graphql-tools/utils';
|
|
6
7
|
var IntrospectionQueryType;
|
|
7
8
|
(function (IntrospectionQueryType) {
|
|
@@ -25,6 +26,7 @@ function getIntrospectionOperationType(operationAST) {
|
|
|
25
26
|
return introspectionQueryType;
|
|
26
27
|
}
|
|
27
28
|
function getExecuteFn(subschema) {
|
|
29
|
+
const compiledQueryCache = new WeakMap();
|
|
28
30
|
return function subschemaExecute(args) {
|
|
29
31
|
const originalRequest = {
|
|
30
32
|
document: args.document,
|
|
@@ -64,7 +66,21 @@ function getExecuteFn(subschema) {
|
|
|
64
66
|
};
|
|
65
67
|
let executor = subschema.executor;
|
|
66
68
|
if (executor == null) {
|
|
67
|
-
executor =
|
|
69
|
+
executor = function subschemaExecutor(request) {
|
|
70
|
+
let compiledQuery = compiledQueryCache.get(args.document);
|
|
71
|
+
if (!compiledQuery) {
|
|
72
|
+
const compilationResult = compileQuery(subschema.schema, request.document, args.operationName ?? undefined);
|
|
73
|
+
if (!isCompiledQuery(compilationResult)) {
|
|
74
|
+
return compilationResult;
|
|
75
|
+
}
|
|
76
|
+
compiledQuery = compilationResult;
|
|
77
|
+
compiledQueryCache.set(args.document, compiledQuery);
|
|
78
|
+
}
|
|
79
|
+
if (operationAST.operation === 'subscription') {
|
|
80
|
+
return compiledQuery.subscribe(request.rootValue, request.context, request.variables);
|
|
81
|
+
}
|
|
82
|
+
return compiledQuery.query(request.rootValue, request.context, request.variables);
|
|
83
|
+
};
|
|
68
84
|
}
|
|
69
85
|
/*
|
|
70
86
|
if (subschema.batch) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/runtime",
|
|
3
|
-
"version": "0.96.
|
|
3
|
+
"version": "0.96.5-alpha-20230913212228-71af2a353",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@graphql-mesh/cross-helpers": "^0.4.0",
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@envelop/core": "^4.0.0",
|
|
15
15
|
"@envelop/extended-validation": "^3.0.0",
|
|
16
|
+
"@envelop/graphql-jit": "^6.0.2",
|
|
16
17
|
"@graphql-mesh/string-interpolation": "^0.5.1",
|
|
17
18
|
"@graphql-tools/batch-delegate": "^9.0.0",
|
|
18
19
|
"@graphql-tools/delegate": "^10.0.0",
|
|
19
20
|
"@graphql-tools/wrap": "^10.0.0",
|
|
20
|
-
"@whatwg-node/fetch": "^0.9.0"
|
|
21
|
+
"@whatwg-node/fetch": "^0.9.0",
|
|
22
|
+
"graphql-jit": "^0.8.4"
|
|
21
23
|
},
|
|
22
24
|
"repository": {
|
|
23
25
|
"type": "git",
|