@graphql-mesh/fusion-runtime 1.4.3 → 1.5.0-alpha-571bfdbc8753ac98190e44caff4e5d28038ee232
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +16 -9
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +16 -9
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @graphql-mesh/fusion-runtime
|
|
2
2
|
|
|
3
|
+
## 1.5.0-alpha-571bfdbc8753ac98190e44caff4e5d28038ee232
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1629](https://github.com/graphql-hive/gateway/pull/1629) [`073a078`](https://github.com/graphql-hive/gateway/commit/073a078c8cdbdd4ec33fdb9d3aeb4955fbcfb103) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Support changing the unified graph handler
|
|
9
|
+
|
|
10
|
+
Allowing users to integrate other query planners, like the new [Hive Gateway Router Runtime](https://the-guild.dev/graphql/hive/docs/gateway/other-features/router-runtime).
|
|
11
|
+
|
|
3
12
|
## 1.4.3
|
|
4
13
|
### Patch Changes
|
|
5
14
|
|
package/dist/index.cjs
CHANGED
|
@@ -1327,7 +1327,7 @@ class UnifiedGraphManager {
|
|
|
1327
1327
|
constructor(opts) {
|
|
1328
1328
|
this.opts = opts;
|
|
1329
1329
|
this.batch = opts.batch ?? true;
|
|
1330
|
-
this.handleUnifiedGraph = opts.handleUnifiedGraph || handleFederationSupergraph;
|
|
1330
|
+
this.handleUnifiedGraph = opts.handleUnifiedGraph || (handleFederationSupergraph);
|
|
1331
1331
|
this.instrumentation = opts.instrumentation ?? (() => void 0);
|
|
1332
1332
|
this.onSubgraphExecuteHooks = opts?.onSubgraphExecuteHooks || [];
|
|
1333
1333
|
this.onDelegationPlanHooks = opts?.onDelegationPlanHooks || [];
|
|
@@ -1429,15 +1429,9 @@ class UnifiedGraphManager {
|
|
|
1429
1429
|
}
|
|
1430
1430
|
return this.unifiedGraph;
|
|
1431
1431
|
}
|
|
1432
|
+
let serializedUnifiedGraph;
|
|
1432
1433
|
if (!doNotCache && this.opts.transportContext?.cache) {
|
|
1433
|
-
|
|
1434
|
-
if (typeof loadedUnifiedGraph === "string") {
|
|
1435
|
-
serializedUnifiedGraph = loadedUnifiedGraph;
|
|
1436
|
-
} else if (graphql.isSchema(loadedUnifiedGraph)) {
|
|
1437
|
-
serializedUnifiedGraph = utils.printSchemaWithDirectives(loadedUnifiedGraph);
|
|
1438
|
-
} else if (utils.isDocumentNode(loadedUnifiedGraph)) {
|
|
1439
|
-
serializedUnifiedGraph = graphql.print(loadedUnifiedGraph);
|
|
1440
|
-
}
|
|
1434
|
+
serializedUnifiedGraph = serializeLoadedUnifiedGraph(loadedUnifiedGraph);
|
|
1441
1435
|
if (serializedUnifiedGraph != null) {
|
|
1442
1436
|
try {
|
|
1443
1437
|
const ttl = this.opts.pollingInterval ? this.opts.pollingInterval * 1e-3 : (
|
|
@@ -1490,6 +1484,10 @@ class UnifiedGraphManager {
|
|
|
1490
1484
|
executor: executor$1
|
|
1491
1485
|
} = this.handleUnifiedGraph({
|
|
1492
1486
|
unifiedGraph: ensuredSchema,
|
|
1487
|
+
getUnifiedGraphSDL() {
|
|
1488
|
+
serializedUnifiedGraph ||= serializeLoadedUnifiedGraph(loadedUnifiedGraph);
|
|
1489
|
+
return serializedUnifiedGraph;
|
|
1490
|
+
},
|
|
1493
1491
|
additionalTypeDefs: this.opts.additionalTypeDefs,
|
|
1494
1492
|
additionalResolvers: this.opts.additionalResolvers,
|
|
1495
1493
|
onSubgraphExecute(subgraphName, execReq) {
|
|
@@ -1706,6 +1704,15 @@ function disposeAll(disposables) {
|
|
|
1706
1704
|
return Promise.all(disposalJobs).then(() => {
|
|
1707
1705
|
});
|
|
1708
1706
|
}
|
|
1707
|
+
function serializeLoadedUnifiedGraph(loadedUnifiedGraph) {
|
|
1708
|
+
if (typeof loadedUnifiedGraph === "string") {
|
|
1709
|
+
return loadedUnifiedGraph;
|
|
1710
|
+
}
|
|
1711
|
+
if (graphql.isSchema(loadedUnifiedGraph)) {
|
|
1712
|
+
return utils.printSchemaWithDirectives(loadedUnifiedGraph);
|
|
1713
|
+
}
|
|
1714
|
+
return transportCommon.defaultPrintFn(loadedUnifiedGraph);
|
|
1715
|
+
}
|
|
1709
1716
|
|
|
1710
1717
|
function getExecutorForUnifiedGraph(opts) {
|
|
1711
1718
|
const unifiedGraphManager = new UnifiedGraphManager(opts);
|
package/dist/index.d.cts
CHANGED
|
@@ -28,6 +28,7 @@ interface BatchDelegateOptions {
|
|
|
28
28
|
type UnifiedGraphHandler = (opts: UnifiedGraphHandlerOpts) => UnifiedGraphHandlerResult;
|
|
29
29
|
interface UnifiedGraphHandlerOpts {
|
|
30
30
|
unifiedGraph: GraphQLSchema;
|
|
31
|
+
getUnifiedGraphSDL(): string;
|
|
31
32
|
additionalTypeDefs?: TypeSource;
|
|
32
33
|
additionalResolvers?: IResolvers<unknown, any> | IResolvers<unknown, any>[];
|
|
33
34
|
onSubgraphExecute: ReturnType<typeof getOnSubgraphExecute>;
|
|
@@ -45,7 +46,7 @@ interface UnifiedGraphHandlerResult {
|
|
|
45
46
|
unifiedGraph: GraphQLSchema;
|
|
46
47
|
executor?: Executor;
|
|
47
48
|
getSubgraphSchema(subgraphName: string): GraphQLSchema;
|
|
48
|
-
inContextSDK
|
|
49
|
+
inContextSDK?: any;
|
|
49
50
|
}
|
|
50
51
|
interface UnifiedGraphManagerOptions<TContext> {
|
|
51
52
|
getUnifiedGraph(ctx: TransportContext | undefined): MaybePromise<GraphQLSchema | string | DocumentNode>;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface BatchDelegateOptions {
|
|
|
28
28
|
type UnifiedGraphHandler = (opts: UnifiedGraphHandlerOpts) => UnifiedGraphHandlerResult;
|
|
29
29
|
interface UnifiedGraphHandlerOpts {
|
|
30
30
|
unifiedGraph: GraphQLSchema;
|
|
31
|
+
getUnifiedGraphSDL(): string;
|
|
31
32
|
additionalTypeDefs?: TypeSource;
|
|
32
33
|
additionalResolvers?: IResolvers<unknown, any> | IResolvers<unknown, any>[];
|
|
33
34
|
onSubgraphExecute: ReturnType<typeof getOnSubgraphExecute>;
|
|
@@ -45,7 +46,7 @@ interface UnifiedGraphHandlerResult {
|
|
|
45
46
|
unifiedGraph: GraphQLSchema;
|
|
46
47
|
executor?: Executor;
|
|
47
48
|
getSubgraphSchema(subgraphName: string): GraphQLSchema;
|
|
48
|
-
inContextSDK
|
|
49
|
+
inContextSDK?: any;
|
|
49
50
|
}
|
|
50
51
|
interface UnifiedGraphManagerOptions<TContext> {
|
|
51
52
|
getUnifiedGraph(ctx: TransportContext | undefined): MaybePromise<GraphQLSchema | string | DocumentNode>;
|
package/dist/index.js
CHANGED
|
@@ -1325,7 +1325,7 @@ class UnifiedGraphManager {
|
|
|
1325
1325
|
constructor(opts) {
|
|
1326
1326
|
this.opts = opts;
|
|
1327
1327
|
this.batch = opts.batch ?? true;
|
|
1328
|
-
this.handleUnifiedGraph = opts.handleUnifiedGraph || handleFederationSupergraph;
|
|
1328
|
+
this.handleUnifiedGraph = opts.handleUnifiedGraph || (handleFederationSupergraph);
|
|
1329
1329
|
this.instrumentation = opts.instrumentation ?? (() => void 0);
|
|
1330
1330
|
this.onSubgraphExecuteHooks = opts?.onSubgraphExecuteHooks || [];
|
|
1331
1331
|
this.onDelegationPlanHooks = opts?.onDelegationPlanHooks || [];
|
|
@@ -1427,15 +1427,9 @@ class UnifiedGraphManager {
|
|
|
1427
1427
|
}
|
|
1428
1428
|
return this.unifiedGraph;
|
|
1429
1429
|
}
|
|
1430
|
+
let serializedUnifiedGraph;
|
|
1430
1431
|
if (!doNotCache && this.opts.transportContext?.cache) {
|
|
1431
|
-
|
|
1432
|
-
if (typeof loadedUnifiedGraph === "string") {
|
|
1433
|
-
serializedUnifiedGraph = loadedUnifiedGraph;
|
|
1434
|
-
} else if (isSchema(loadedUnifiedGraph)) {
|
|
1435
|
-
serializedUnifiedGraph = printSchemaWithDirectives(loadedUnifiedGraph);
|
|
1436
|
-
} else if (isDocumentNode(loadedUnifiedGraph)) {
|
|
1437
|
-
serializedUnifiedGraph = print(loadedUnifiedGraph);
|
|
1438
|
-
}
|
|
1432
|
+
serializedUnifiedGraph = serializeLoadedUnifiedGraph(loadedUnifiedGraph);
|
|
1439
1433
|
if (serializedUnifiedGraph != null) {
|
|
1440
1434
|
try {
|
|
1441
1435
|
const ttl = this.opts.pollingInterval ? this.opts.pollingInterval * 1e-3 : (
|
|
@@ -1488,6 +1482,10 @@ class UnifiedGraphManager {
|
|
|
1488
1482
|
executor
|
|
1489
1483
|
} = this.handleUnifiedGraph({
|
|
1490
1484
|
unifiedGraph: ensuredSchema,
|
|
1485
|
+
getUnifiedGraphSDL() {
|
|
1486
|
+
serializedUnifiedGraph ||= serializeLoadedUnifiedGraph(loadedUnifiedGraph);
|
|
1487
|
+
return serializedUnifiedGraph;
|
|
1488
|
+
},
|
|
1491
1489
|
additionalTypeDefs: this.opts.additionalTypeDefs,
|
|
1492
1490
|
additionalResolvers: this.opts.additionalResolvers,
|
|
1493
1491
|
onSubgraphExecute(subgraphName, execReq) {
|
|
@@ -1704,6 +1702,15 @@ function disposeAll(disposables) {
|
|
|
1704
1702
|
return Promise.all(disposalJobs).then(() => {
|
|
1705
1703
|
});
|
|
1706
1704
|
}
|
|
1705
|
+
function serializeLoadedUnifiedGraph(loadedUnifiedGraph) {
|
|
1706
|
+
if (typeof loadedUnifiedGraph === "string") {
|
|
1707
|
+
return loadedUnifiedGraph;
|
|
1708
|
+
}
|
|
1709
|
+
if (isSchema(loadedUnifiedGraph)) {
|
|
1710
|
+
return printSchemaWithDirectives(loadedUnifiedGraph);
|
|
1711
|
+
}
|
|
1712
|
+
return defaultPrintFn(loadedUnifiedGraph);
|
|
1713
|
+
}
|
|
1707
1714
|
|
|
1708
1715
|
function getExecutorForUnifiedGraph(opts) {
|
|
1709
1716
|
const unifiedGraphManager = new UnifiedGraphManager(opts);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/fusion-runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-alpha-571bfdbc8753ac98190e44caff4e5d28038ee232",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime for GraphQL Mesh Fusion Supergraph",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
|
-
"build": "pkgroll --clean-dist && node scripts/replace-import-with-require.mjs",
|
|
39
|
+
"build": "pkgroll --clean-dist --env.HIVE_ROUTER_RUNTIME='\"0\"' && node scripts/replace-import-with-require.mjs",
|
|
40
40
|
"prepack": "yarn build"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"tslib": "^2.8.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
+
"@graphql-hive/router-runtime": "1.0.0-alpha-571bfdbc8753ac98190e44caff4e5d28038ee232",
|
|
68
69
|
"change-case": "^5.4.4",
|
|
69
70
|
"graphql": "^16.12.0",
|
|
70
71
|
"pkgroll": "2.20.1"
|