@graphql-mesh/fusion-runtime 1.11.8 → 1.11.9

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @graphql-mesh/fusion-runtime
2
2
 
3
+ ## 1.11.9
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#2542](https://github.com/graphql-hive/gateway/pull/2542) [`48e4ab3`](https://github.com/graphql-hive/gateway/commit/48e4ab36ac50dbd29c4855bb8087989b128e4351) Thanks [@dotansimha](https://github.com/dotansimha)! - ### Expose `cache` instance to unified graph handler
9
+
10
+ The gateway `UnifiedGraphHandlerOpts` now includes an optinal `cache` instance that can be passed to the handler from the gateway.
11
+
3
12
  ## 1.11.8
4
13
  ### Patch Changes
5
14
 
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ var transportCommon = require('@graphql-mesh/transport-common');
6
6
  var utils$1 = require('@graphql-mesh/utils');
7
7
  var batchExecute = require('@graphql-tools/batch-execute');
8
8
  var utils = require('@graphql-tools/utils');
9
- var promiseHelpers = require('@whatwg-node/promise-helpers');
9
+ var require$$3 = require('@whatwg-node/promise-helpers');
10
10
  var graphql = require('graphql');
11
11
  var delegate = require('@graphql-tools/delegate');
12
12
  var federation = require('@graphql-tools/federation');
@@ -15,7 +15,7 @@ var stitch = require('@graphql-tools/stitch');
15
15
  var stitchingDirectives = require('@graphql-tools/stitching-directives');
16
16
  var wrap = require('@graphql-tools/wrap');
17
17
  var executor = require('@graphql-tools/executor');
18
- var disposablestack = require('@whatwg-node/disposablestack');
18
+ var require$$1 = require('@whatwg-node/disposablestack');
19
19
 
20
20
  // Regexps involved with splitting words in various case formats.
21
21
  const SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
@@ -883,7 +883,7 @@ const handleFederationSupergraph = function({
883
883
  if (directiveExtensions.pubsubPublish?.length) {
884
884
  const originalResolve = fieldConfig.resolve || delegate.defaultMergedResolver;
885
885
  fieldConfig.resolve = function(root, args, context, info) {
886
- return promiseHelpers.handleMaybePromise(
886
+ return require$$3.handleMaybePromise(
887
887
  () => originalResolve(root, args, context, info),
888
888
  (payload) => {
889
889
  const jobs = [];
@@ -892,7 +892,7 @@ const handleFederationSupergraph = function({
892
892
  pubsubPublishArgs.pubsubTopic,
893
893
  payload
894
894
  );
895
- if (promiseHelpers.isPromise(job)) {
895
+ if (require$$3.isPromise(job)) {
896
896
  jobs.push(job);
897
897
  }
898
898
  }
@@ -933,7 +933,7 @@ const handleFederationSupergraph = function({
933
933
 
934
934
  function defaultTransportsGetter(kind) {
935
935
  const moduleName = `@graphql-mesh/transport-${kind}`;
936
- return promiseHelpers.handleMaybePromise(
936
+ return require$$3.handleMaybePromise(
937
937
  () => require(moduleName),
938
938
  (transport) => {
939
939
  if (!transport) {
@@ -977,7 +977,7 @@ function getTransportExecutor({
977
977
  }) {
978
978
  const kind = transportEntry?.kind || "";
979
979
  transportContext?.log.debug(`Loading transport "${kind}"`);
980
- return promiseHelpers.handleMaybePromise(
980
+ return require$$3.handleMaybePromise(
981
981
  () => typeof transports === "function" ? transports(kind) : transports[kind],
982
982
  (transport) => {
983
983
  if (!transport) {
@@ -1051,7 +1051,7 @@ function getOnSubgraphExecute({
1051
1051
  log.debug("Initializing executor");
1052
1052
  }
1053
1053
  executor = function lazyExecutor(subgraphExecReq) {
1054
- return promiseHelpers.handleMaybePromise(
1054
+ return require$$3.handleMaybePromise(
1055
1055
  () => (
1056
1056
  // Gets the transport executor for the given subgraph
1057
1057
  getTransportExecutor({
@@ -1118,7 +1118,7 @@ function wrapExecutorWithHooks({
1118
1118
  let executor = baseExecutor;
1119
1119
  let executionRequest = baseExecutionRequest;
1120
1120
  const onSubgraphExecuteDoneHooks = [];
1121
- return promiseHelpers.handleMaybePromise(
1121
+ return require$$3.handleMaybePromise(
1122
1122
  () => utils$1.iterateAsync(
1123
1123
  onSubgraphExecuteHooks,
1124
1124
  (onSubgraphExecuteHook) => onSubgraphExecuteHook({
@@ -1146,11 +1146,11 @@ function wrapExecutorWithHooks({
1146
1146
  if (onSubgraphExecuteDoneHooks.length === 0) {
1147
1147
  return executor(executionRequest);
1148
1148
  }
1149
- return promiseHelpers.handleMaybePromise(
1149
+ return require$$3.handleMaybePromise(
1150
1150
  () => executor(executionRequest),
1151
1151
  (currentResult) => {
1152
1152
  const executeDoneResults = [];
1153
- return promiseHelpers.handleMaybePromise(
1153
+ return require$$3.handleMaybePromise(
1154
1154
  () => utils$1.iterateAsync(
1155
1155
  onSubgraphExecuteDoneHooks,
1156
1156
  (onSubgraphExecuteDoneHook) => onSubgraphExecuteDoneHook({
@@ -1182,9 +1182,9 @@ function wrapExecutorWithHooks({
1182
1182
  if (onNextHooks.length === 0 && onEndHooks.length === 0) {
1183
1183
  return currentResult;
1184
1184
  }
1185
- return promiseHelpers.mapAsyncIterator(
1185
+ return require$$3.mapAsyncIterator(
1186
1186
  currentResult,
1187
- (currentResult2) => promiseHelpers.handleMaybePromise(
1187
+ (currentResult2) => require$$3.handleMaybePromise(
1188
1188
  () => utils$1.iterateAsync(
1189
1189
  onNextHooks,
1190
1190
  (onNext) => onNext({
@@ -1269,7 +1269,7 @@ function wrapMergedTypeResolver(originalResolver, typeName, onDelegationStageExe
1269
1269
  onDelegationStageExecuteDoneHooks.push(onDelegationStageExecuteDone);
1270
1270
  }
1271
1271
  }
1272
- return promiseHelpers.handleMaybePromise(
1272
+ return require$$3.handleMaybePromise(
1273
1273
  () => resolver(
1274
1274
  object,
1275
1275
  context,
@@ -1449,7 +1449,7 @@ class UnifiedGraphManager {
1449
1449
  ensureUnifiedGraph() {
1450
1450
  if (this.polling$ == null && this.opts?.pollingInterval != null && this.lastLoadTime != null && Date.now() - this.lastLoadTime >= this.opts.pollingInterval) {
1451
1451
  this.opts?.transportContext?.log.debug(`Polling Supergraph`);
1452
- this.polling$ = promiseHelpers.handleMaybePromise(
1452
+ this.polling$ = require$$3.handleMaybePromise(
1453
1453
  () => this.getAndSetUnifiedGraph(),
1454
1454
  () => {
1455
1455
  this.polling$ = void 0;
@@ -1473,7 +1473,7 @@ class UnifiedGraphManager {
1473
1473
  { key: UNIFIEDGRAPH_CACHE_KEY },
1474
1474
  "Searching for Supergraph in cache..."
1475
1475
  );
1476
- this.initialUnifiedGraph$ = promiseHelpers.handleMaybePromise(
1476
+ this.initialUnifiedGraph$ = require$$3.handleMaybePromise(
1477
1477
  () => this.opts.transportContext?.cache?.get(UNIFIEDGRAPH_CACHE_KEY),
1478
1478
  (cachedUnifiedGraph) => {
1479
1479
  if (cachedUnifiedGraph) {
@@ -1492,7 +1492,7 @@ class UnifiedGraphManager {
1492
1492
  } else {
1493
1493
  this.initialUnifiedGraph$ = this.getAndSetUnifiedGraph();
1494
1494
  }
1495
- this.initialUnifiedGraph$ = promiseHelpers.handleMaybePromise(
1495
+ this.initialUnifiedGraph$ = require$$3.handleMaybePromise(
1496
1496
  () => this.initialUnifiedGraph$,
1497
1497
  (v) => {
1498
1498
  this.initialUnifiedGraph$ = void 0;
@@ -1549,7 +1549,7 @@ class UnifiedGraphManager {
1549
1549
  serializedUnifiedGraph,
1550
1550
  { ttl }
1551
1551
  );
1552
- if (promiseHelpers.isPromise(result)) {
1552
+ if (require$$3.isPromise(result)) {
1553
1553
  cacheSet$ = result;
1554
1554
  result.then(() => {
1555
1555
  }, logCacheSetError);
@@ -1571,7 +1571,7 @@ class UnifiedGraphManager {
1571
1571
  this.opts.transportEntryAdditions
1572
1572
  );
1573
1573
  let onSubgraphExecute;
1574
- return promiseHelpers.handleMaybePromise(
1574
+ return require$$3.handleMaybePromise(
1575
1575
  () => this.handleUnifiedGraph({
1576
1576
  unifiedGraph: ensuredSchema,
1577
1577
  getUnifiedGraphSDL() {
@@ -1588,6 +1588,7 @@ class UnifiedGraphManager {
1588
1588
  onDelegateHooks: this.opts.onDelegateHooks,
1589
1589
  batchDelegateOptions: this.opts.batchDelegateOptions,
1590
1590
  log: this.opts.transportContext?.log,
1591
+ cache: this.opts.transportContext?.cache,
1591
1592
  handleProgressiveOverride: this.opts.handleProgressiveOverride ? (label, context) => {
1592
1593
  const labels = this.overrideLabelsByContext.get(context);
1593
1594
  if (labels?.has(label)) {
@@ -1604,7 +1605,7 @@ class UnifiedGraphManager {
1604
1605
  overrideLabels
1605
1606
  }) => {
1606
1607
  this.overrideLabels = overrideLabels;
1607
- const transportExecutorStack = new disposablestack.AsyncDisposableStack();
1608
+ const transportExecutorStack = new require$$1.AsyncDisposableStack();
1608
1609
  const generation = {
1609
1610
  executor,
1610
1611
  transportExecutorStack,
@@ -1645,7 +1646,7 @@ class UnifiedGraphManager {
1645
1646
  this.opts.transportContext?.log.debug(
1646
1647
  "Supergraph has been changed, updating..."
1647
1648
  );
1648
- return promiseHelpers.handleMaybePromise(
1649
+ return require$$3.handleMaybePromise(
1649
1650
  () => disposePrevious,
1650
1651
  () => this.unifiedGraph,
1651
1652
  (err) => {
@@ -1774,7 +1775,7 @@ class UnifiedGraphManager {
1774
1775
  generation.forceDisposeTimer = void 0;
1775
1776
  }
1776
1777
  this.drainingGenerations.delete(generation);
1777
- return promiseHelpers.handleMaybePromise(
1778
+ return require$$3.handleMaybePromise(
1778
1779
  () => disposeAll([generation.transportExecutorStack, generation.executor]),
1779
1780
  () => void 0,
1780
1781
  (err) => {
@@ -1786,7 +1787,7 @@ class UnifiedGraphManager {
1786
1787
  );
1787
1788
  }
1788
1789
  getAndSetUnifiedGraph() {
1789
- return promiseHelpers.handleMaybePromise(
1790
+ return require$$3.handleMaybePromise(
1790
1791
  () => this.opts.getUnifiedGraph(this.opts.transportContext),
1791
1792
  (loadedUnifiedGraph) => this.handleLoadedUnifiedGraph(loadedUnifiedGraph),
1792
1793
  (err) => {
@@ -1802,7 +1803,7 @@ class UnifiedGraphManager {
1802
1803
  );
1803
1804
  }
1804
1805
  getUnifiedGraph() {
1805
- return promiseHelpers.handleMaybePromise(
1806
+ return require$$3.handleMaybePromise(
1806
1807
  () => this.ensureUnifiedGraph(),
1807
1808
  () => {
1808
1809
  if (!this.unifiedGraph) {
@@ -1813,13 +1814,13 @@ class UnifiedGraphManager {
1813
1814
  );
1814
1815
  }
1815
1816
  getExecutor() {
1816
- return promiseHelpers.handleMaybePromise(
1817
+ return require$$3.handleMaybePromise(
1817
1818
  () => this.ensureUnifiedGraph(),
1818
1819
  () => this.currentGeneration?.executor
1819
1820
  );
1820
1821
  }
1821
1822
  getContext(base = {}) {
1822
- return promiseHelpers.handleMaybePromise(
1823
+ return require$$3.handleMaybePromise(
1823
1824
  () => this.ensureUnifiedGraph(),
1824
1825
  () => {
1825
1826
  if (this.inContextSDK) {
@@ -1847,7 +1848,7 @@ class UnifiedGraphManager {
1847
1848
  labels.add(label);
1848
1849
  }
1849
1850
  };
1850
- if (promiseHelpers.isPromise(result$)) {
1851
+ if (require$$3.isPromise(result$)) {
1851
1852
  jobs$.push(result$.then(handleResult));
1852
1853
  } else {
1853
1854
  handleResult(result$);
@@ -1862,7 +1863,7 @@ class UnifiedGraphManager {
1862
1863
  );
1863
1864
  }
1864
1865
  getTransportEntryMap() {
1865
- return promiseHelpers.handleMaybePromise(
1866
+ return require$$3.handleMaybePromise(
1866
1867
  () => this.ensureUnifiedGraph(),
1867
1868
  () => {
1868
1869
  if (!this._transportEntryMap) {
@@ -1875,7 +1876,7 @@ class UnifiedGraphManager {
1875
1876
  invalidateUnifiedGraph() {
1876
1877
  return this.getAndSetUnifiedGraph();
1877
1878
  }
1878
- [disposablestack.DisposableSymbols.asyncDispose]() {
1879
+ [require$$1.DisposableSymbols.asyncDispose]() {
1879
1880
  this.disposeReason = utils.createGraphQLError(
1880
1881
  "operation has been aborted because the server is shutting down",
1881
1882
  {
@@ -1903,7 +1904,7 @@ class UnifiedGraphManager {
1903
1904
  disposables.push(generation.transportExecutorStack, generation.executor);
1904
1905
  }
1905
1906
  this.drainingGenerations.clear();
1906
- return promiseHelpers.handleMaybePromise(
1907
+ return require$$3.handleMaybePromise(
1907
1908
  () => disposeAll(disposables),
1908
1909
  () => {
1909
1910
  this.unifiedGraph = void 0;
@@ -1921,7 +1922,7 @@ class UnifiedGraphManager {
1921
1922
  function disposeAll(disposables) {
1922
1923
  const disposalJobs = disposables.map(
1923
1924
  (disposable) => utils$1.isDisposable(disposable) ? utils$1.dispose(disposable) : void 0
1924
- ).filter(promiseHelpers.isPromise);
1925
+ ).filter(require$$3.isPromise);
1925
1926
  if (disposalJobs.length === 0) {
1926
1927
  return void 0;
1927
1928
  } else if (disposalJobs.length === 1) {
@@ -1943,7 +1944,7 @@ function serializeLoadedUnifiedGraph(loadedUnifiedGraph) {
1943
1944
  function getExecutorForUnifiedGraph(opts) {
1944
1945
  const unifiedGraphManager = new UnifiedGraphManager(opts);
1945
1946
  const unifiedGraphExecutor = function unifiedGraphExecutor2(execReq) {
1946
- return promiseHelpers.handleMaybePromise(
1947
+ return require$$3.handleMaybePromise(
1947
1948
  () => unifiedGraphManager.getContext(execReq.context),
1948
1949
  (context) => {
1949
1950
  function handleExecutor(executor) {
@@ -1956,11 +1957,11 @@ function getExecutorForUnifiedGraph(opts) {
1956
1957
  context
1957
1958
  });
1958
1959
  }
1959
- return promiseHelpers.handleMaybePromise(
1960
+ return require$$3.handleMaybePromise(
1960
1961
  () => unifiedGraphManager.getExecutor(),
1961
1962
  (executor) => {
1962
1963
  if (!executor) {
1963
- return promiseHelpers.handleMaybePromise(
1964
+ return require$$3.handleMaybePromise(
1964
1965
  () => unifiedGraphManager.getUnifiedGraph(),
1965
1966
  (unifiedGraph) => {
1966
1967
  opts?.transportContext?.log.debug(
@@ -1982,7 +1983,7 @@ function getExecutorForUnifiedGraph(opts) {
1982
1983
  unifiedGraphExecutor,
1983
1984
  function unifiedGraphExecutorDispose() {
1984
1985
  opts?.transportContext?.log.debug("Disposing unified graph executor");
1985
- return unifiedGraphManager[disposablestack.DisposableSymbols.asyncDispose]();
1986
+ return unifiedGraphManager[require$$1.DisposableSymbols.asyncDispose]();
1986
1987
  }
1987
1988
  );
1988
1989
  }
@@ -1996,7 +1997,7 @@ function getSdkRequesterForUnifiedGraph(opts) {
1996
1997
  variables,
1997
1998
  context: operationContext
1998
1999
  };
1999
- return promiseHelpers.handleMaybePromise(
2000
+ return require$$3.handleMaybePromise(
2000
2001
  () => onExecutionRequest(executionRequest),
2001
2002
  (onExecutionRequestResult) => {
2002
2003
  if (onExecutionRequestResult != null) {
@@ -2008,7 +2009,7 @@ function getSdkRequesterForUnifiedGraph(opts) {
2008
2009
  opts?.dataLoaderOptions,
2009
2010
  opts?.extensionsReducer
2010
2011
  ) : unifiedGraphExecutor;
2011
- return promiseHelpers.handleMaybePromise(
2012
+ return require$$3.handleMaybePromise(
2012
2013
  () => executor(executionRequest),
2013
2014
  handleMaybePromiseMaybeAsyncIterableResult
2014
2015
  );
@@ -2017,11 +2018,11 @@ function getSdkRequesterForUnifiedGraph(opts) {
2017
2018
  };
2018
2019
  }
2019
2020
  function handleMaybePromiseMaybeAsyncIterableResult(result) {
2020
- return promiseHelpers.handleMaybePromise(
2021
+ return require$$3.handleMaybePromise(
2021
2022
  () => result,
2022
2023
  (resolvedResult) => {
2023
2024
  if (utils.isAsyncIterable(resolvedResult)) {
2024
- return promiseHelpers.mapAsyncIterator(resolvedResult, extractDataOrThrowErrors);
2025
+ return require$$3.mapAsyncIterator(resolvedResult, extractDataOrThrowErrors);
2025
2026
  }
2026
2027
  return extractDataOrThrowErrors(resolvedResult);
2027
2028
  }
package/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@ export { TransportEntry, TransportGetSubgraphExecutor, TransportGetSubgraphExecu
6
6
  import { DelegationPlanBuilder, Subschema, MergedTypeResolver, SubschemaConfig } from '@graphql-tools/delegate';
7
7
  import { GraphQLSchema, DocumentNode, ExecutionResult, GraphQLError, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from 'graphql';
8
8
  import { GraphQLResolveInfo, GraphQLOutputType } from 'graphql/type';
9
- import { OnDelegateHook } from '@graphql-mesh/types';
9
+ import { OnDelegateHook, KeyValueCache } from '@graphql-mesh/types';
10
10
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
11
11
  import { MaybePromise } from '@whatwg-node/promise-helpers';
12
12
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
@@ -41,6 +41,8 @@ interface UnifiedGraphHandlerOpts {
41
41
  */
42
42
  batchDelegateOptions?: BatchDelegateOptions;
43
43
  log?: Logger;
44
+ /** Shared cache instance (e.g. Redis), used by handlers that support cross-process caching. */
45
+ cache?: KeyValueCache;
44
46
  }
45
47
  interface UnifiedGraphHandlerResult {
46
48
  unifiedGraph: GraphQLSchema;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { TransportEntry, TransportGetSubgraphExecutor, TransportGetSubgraphExecu
6
6
  import { DelegationPlanBuilder, Subschema, MergedTypeResolver, SubschemaConfig } from '@graphql-tools/delegate';
7
7
  import { GraphQLSchema, DocumentNode, ExecutionResult, GraphQLError, FragmentDefinitionNode, SelectionNode, SelectionSetNode } from 'graphql';
8
8
  import { GraphQLResolveInfo, GraphQLOutputType } from 'graphql/type';
9
- import { OnDelegateHook } from '@graphql-mesh/types';
9
+ import { OnDelegateHook, KeyValueCache } from '@graphql-mesh/types';
10
10
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
11
11
  import { MaybePromise } from '@whatwg-node/promise-helpers';
12
12
  import { getBatchingExecutor } from '@graphql-tools/batch-execute';
@@ -41,6 +41,8 @@ interface UnifiedGraphHandlerOpts {
41
41
  */
42
42
  batchDelegateOptions?: BatchDelegateOptions;
43
43
  log?: Logger;
44
+ /** Shared cache instance (e.g. Redis), used by handlers that support cross-process caching. */
45
+ cache?: KeyValueCache;
44
46
  }
45
47
  interface UnifiedGraphHandlerResult {
46
48
  unifiedGraph: GraphQLSchema;
package/dist/index.js CHANGED
@@ -1586,6 +1586,7 @@ class UnifiedGraphManager {
1586
1586
  onDelegateHooks: this.opts.onDelegateHooks,
1587
1587
  batchDelegateOptions: this.opts.batchDelegateOptions,
1588
1588
  log: this.opts.transportContext?.log,
1589
+ cache: this.opts.transportContext?.cache,
1589
1590
  handleProgressiveOverride: this.opts.handleProgressiveOverride ? (label, context) => {
1590
1591
  const labels = this.overrideLabelsByContext.get(context);
1591
1592
  if (labels?.has(label)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-mesh/fusion-runtime",
3
- "version": "1.11.8",
3
+ "version": "1.11.9",
4
4
  "type": "module",
5
5
  "description": "Runtime for GraphQL Mesh Fusion Supergraph",
6
6
  "repository": {
@@ -65,7 +65,7 @@
65
65
  "tslib": "^2.8.1"
66
66
  },
67
67
  "devDependencies": {
68
- "@graphql-hive/router-runtime": "^1.4.25",
68
+ "@graphql-hive/router-runtime": "^1.5.0",
69
69
  "change-case": "^5.4.4",
70
70
  "graphql": "^16.12.0",
71
71
  "pkgroll": "2.27.1"