@graphql-hive/gateway-runtime 2.1.1 → 2.1.2-alpha-deebbdd6955e1018f8702ddf86ee8da5c9cca8e7

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,25 @@
1
1
  # @graphql-hive/gateway-runtime
2
2
 
3
+ ## 2.1.2-alpha-deebbdd6955e1018f8702ddf86ee8da5c9cca8e7
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#1474](https://github.com/graphql-hive/gateway/pull/1474) [`537ea70`](https://github.com/graphql-hive/gateway/commit/537ea70dc0ad16e5f48686f7c4b2efaba6f3ab59) Thanks [@ardatan](https://github.com/ardatan)! - In `persistedDocuments` options, `allowArbitraryOperations` flag has been deprecated, and introduced `allowArbitraryDocuments` for both Hive Console and custom store sources
9
+
10
+ ```diff
11
+ defineConfig({
12
+ /* .. */
13
+ persistedDocuments: {
14
+ /* .. */
15
+ - allowArbitraryOperations: true,
16
+ + allowArbitraryDocuments: true,
17
+ },
18
+ });
19
+ ```
20
+ - Updated dependencies []:
21
+ - @graphql-mesh/hmac-upstream-signature@2.0.1
22
+
3
23
  ## 2.1.1
4
24
  ### Patch Changes
5
25
 
package/dist/index.cjs CHANGED
@@ -577,7 +577,7 @@ function useHiveConsole({
577
577
  });
578
578
  }
579
579
 
580
- function getReportingPlugin(config, configContext) {
580
+ function getReportingPlugin(config, configContext, allowArbitraryDocuments = false) {
581
581
  if (config.reporting?.type === "hive") {
582
582
  const { target, ...reporting } = config.reporting;
583
583
  let usage = reporting.usage;
@@ -598,7 +598,8 @@ function getReportingPlugin(config, configContext) {
598
598
  endpoint: config.persistedDocuments.endpoint,
599
599
  accessToken: config.persistedDocuments.token
600
600
  },
601
- allowArbitraryDocuments: !!config.persistedDocuments.allowArbitraryDocuments
601
+ // Trick to satisfy the Hive Console plugin types
602
+ allowArbitraryDocuments
602
603
  }
603
604
  } : {}
604
605
  });
@@ -1994,9 +1995,16 @@ function createGatewayRuntime(config) {
1994
1995
  let replaceSchema = (newSchema) => {
1995
1996
  unifiedGraph = newSchema;
1996
1997
  };
1998
+ let allowArbitraryDocumentsForPersistedDocuments = false;
1999
+ if (config.persistedDocuments?.allowArbitraryDocuments != null) {
2000
+ allowArbitraryDocumentsForPersistedDocuments = config.persistedDocuments?.allowArbitraryDocuments;
2001
+ } else if (config.persistedDocuments?.allowArbitraryOperations) {
2002
+ allowArbitraryDocumentsForPersistedDocuments = config.persistedDocuments?.allowArbitraryOperations;
2003
+ }
1997
2004
  const reportingWithMaybePersistedDocumentsPlugin = getReportingPlugin(
1998
2005
  config,
1999
- configContext
2006
+ configContext,
2007
+ allowArbitraryDocumentsForPersistedDocuments
2000
2008
  );
2001
2009
  let persistedDocumentsPlugin = {};
2002
2010
  if (config.reporting?.type !== "hive" && config.persistedDocuments && "type" in config.persistedDocuments && config.persistedDocuments?.type === "hive") {
@@ -2010,14 +2018,16 @@ function createGatewayRuntime(config) {
2010
2018
  endpoint: config.persistedDocuments.endpoint,
2011
2019
  accessToken: config.persistedDocuments.token
2012
2020
  },
2013
- allowArbitraryDocuments: !!config.persistedDocuments.allowArbitraryDocuments
2021
+ // @ts-expect-error - Hive Console plugin options are not compatible yet
2022
+ allowArbitraryDocuments: allowArbitraryDocumentsForPersistedDocuments
2014
2023
  }
2015
2024
  });
2016
2025
  } else if (config.persistedDocuments && "getPersistedOperation" in config.persistedDocuments) {
2017
2026
  const plugin = pluginPersistedOperations.usePersistedOperations({
2018
2027
  extractPersistedOperationId: defaultExtractPersistedOperationId,
2019
2028
  ...configContext,
2020
- ...config.persistedDocuments
2029
+ ...config.persistedDocuments,
2030
+ allowArbitraryOperations: allowArbitraryDocumentsForPersistedDocuments
2021
2031
  });
2022
2032
  persistedDocumentsPlugin = plugin;
2023
2033
  }
package/dist/index.d.cts CHANGED
@@ -483,12 +483,44 @@ interface GatewayHivePersistedDocumentsOptions {
483
483
  * @default false
484
484
  */
485
485
  allowArbitraryDocuments?: boolean | ((request: Request) => MaybePromise<boolean>);
486
+ /**
487
+ * Whether arbitrary documents should be allowed along-side persisted documents.
488
+ *
489
+ * Alternatively, you can provide a function that returns a boolean value based on
490
+ * the request's headers.
491
+ *
492
+ * @default false
493
+ *
494
+ * @deprecated This option is deprecated and will be removed in the next major version. Use `allowArbitraryDocuments` instead.
495
+ */
496
+ allowArbitraryOperations?: boolean | ((request: Request) => MaybePromise<boolean>);
486
497
  }
487
498
  interface GatewayConfigBase<TContext extends Record<string, any>> {
488
499
  /** Usage reporting options. */
489
500
  reporting?: GatewayHiveReportingOptions | GatewayGraphOSReportingOptions;
490
501
  /** Persisted documents options. */
491
- persistedDocuments?: GatewayHivePersistedDocumentsOptions | UsePersistedOperationsOptions<GatewayContext>;
502
+ persistedDocuments?: GatewayHivePersistedDocumentsOptions | (Omit<UsePersistedOperationsOptions<GatewayContext>, 'allowArbitraryOperations'> & {
503
+ /**
504
+ * Whether arbitrary documents should be allowed along-side persisted documents.
505
+ *
506
+ * Alternatively, you can provide a function that returns a boolean value based on
507
+ * the request's headers.
508
+ *
509
+ * @default false
510
+ */
511
+ allowArbitraryDocuments?: boolean | ((request: Request) => MaybePromise<boolean>);
512
+ /**
513
+ * Whether arbitrary documents should be allowed along-side persisted documents.
514
+ *
515
+ * Alternatively, you can provide a function that returns a boolean value based on
516
+ * the request's headers.
517
+ *
518
+ * @default false
519
+ *
520
+ * @deprecated This option is deprecated and will be removed in the next major version. Use `allowArbitraryDocuments` instead.
521
+ */
522
+ allowArbitraryOperations?: boolean | ((request: Request) => MaybePromise<boolean>);
523
+ });
492
524
  /**
493
525
  * A map, or factory function, of transport kinds to their implementations.
494
526
  *
package/dist/index.d.ts CHANGED
@@ -483,12 +483,44 @@ interface GatewayHivePersistedDocumentsOptions {
483
483
  * @default false
484
484
  */
485
485
  allowArbitraryDocuments?: boolean | ((request: Request) => MaybePromise<boolean>);
486
+ /**
487
+ * Whether arbitrary documents should be allowed along-side persisted documents.
488
+ *
489
+ * Alternatively, you can provide a function that returns a boolean value based on
490
+ * the request's headers.
491
+ *
492
+ * @default false
493
+ *
494
+ * @deprecated This option is deprecated and will be removed in the next major version. Use `allowArbitraryDocuments` instead.
495
+ */
496
+ allowArbitraryOperations?: boolean | ((request: Request) => MaybePromise<boolean>);
486
497
  }
487
498
  interface GatewayConfigBase<TContext extends Record<string, any>> {
488
499
  /** Usage reporting options. */
489
500
  reporting?: GatewayHiveReportingOptions | GatewayGraphOSReportingOptions;
490
501
  /** Persisted documents options. */
491
- persistedDocuments?: GatewayHivePersistedDocumentsOptions | UsePersistedOperationsOptions<GatewayContext>;
502
+ persistedDocuments?: GatewayHivePersistedDocumentsOptions | (Omit<UsePersistedOperationsOptions<GatewayContext>, 'allowArbitraryOperations'> & {
503
+ /**
504
+ * Whether arbitrary documents should be allowed along-side persisted documents.
505
+ *
506
+ * Alternatively, you can provide a function that returns a boolean value based on
507
+ * the request's headers.
508
+ *
509
+ * @default false
510
+ */
511
+ allowArbitraryDocuments?: boolean | ((request: Request) => MaybePromise<boolean>);
512
+ /**
513
+ * Whether arbitrary documents should be allowed along-side persisted documents.
514
+ *
515
+ * Alternatively, you can provide a function that returns a boolean value based on
516
+ * the request's headers.
517
+ *
518
+ * @default false
519
+ *
520
+ * @deprecated This option is deprecated and will be removed in the next major version. Use `allowArbitraryDocuments` instead.
521
+ */
522
+ allowArbitraryOperations?: boolean | ((request: Request) => MaybePromise<boolean>);
523
+ });
492
524
  /**
493
525
  * A map, or factory function, of transport kinds to their implementations.
494
526
  *
package/dist/index.js CHANGED
@@ -576,7 +576,7 @@ function useHiveConsole({
576
576
  });
577
577
  }
578
578
 
579
- function getReportingPlugin(config, configContext) {
579
+ function getReportingPlugin(config, configContext, allowArbitraryDocuments = false) {
580
580
  if (config.reporting?.type === "hive") {
581
581
  const { target, ...reporting } = config.reporting;
582
582
  let usage = reporting.usage;
@@ -597,7 +597,8 @@ function getReportingPlugin(config, configContext) {
597
597
  endpoint: config.persistedDocuments.endpoint,
598
598
  accessToken: config.persistedDocuments.token
599
599
  },
600
- allowArbitraryDocuments: !!config.persistedDocuments.allowArbitraryDocuments
600
+ // Trick to satisfy the Hive Console plugin types
601
+ allowArbitraryDocuments
601
602
  }
602
603
  } : {}
603
604
  });
@@ -1993,9 +1994,16 @@ function createGatewayRuntime(config) {
1993
1994
  let replaceSchema = (newSchema) => {
1994
1995
  unifiedGraph = newSchema;
1995
1996
  };
1997
+ let allowArbitraryDocumentsForPersistedDocuments = false;
1998
+ if (config.persistedDocuments?.allowArbitraryDocuments != null) {
1999
+ allowArbitraryDocumentsForPersistedDocuments = config.persistedDocuments?.allowArbitraryDocuments;
2000
+ } else if (config.persistedDocuments?.allowArbitraryOperations) {
2001
+ allowArbitraryDocumentsForPersistedDocuments = config.persistedDocuments?.allowArbitraryOperations;
2002
+ }
1996
2003
  const reportingWithMaybePersistedDocumentsPlugin = getReportingPlugin(
1997
2004
  config,
1998
- configContext
2005
+ configContext,
2006
+ allowArbitraryDocumentsForPersistedDocuments
1999
2007
  );
2000
2008
  let persistedDocumentsPlugin = {};
2001
2009
  if (config.reporting?.type !== "hive" && config.persistedDocuments && "type" in config.persistedDocuments && config.persistedDocuments?.type === "hive") {
@@ -2009,14 +2017,16 @@ function createGatewayRuntime(config) {
2009
2017
  endpoint: config.persistedDocuments.endpoint,
2010
2018
  accessToken: config.persistedDocuments.token
2011
2019
  },
2012
- allowArbitraryDocuments: !!config.persistedDocuments.allowArbitraryDocuments
2020
+ // @ts-expect-error - Hive Console plugin options are not compatible yet
2021
+ allowArbitraryDocuments: allowArbitraryDocumentsForPersistedDocuments
2013
2022
  }
2014
2023
  });
2015
2024
  } else if (config.persistedDocuments && "getPersistedOperation" in config.persistedDocuments) {
2016
2025
  const plugin = usePersistedOperations({
2017
2026
  extractPersistedOperationId: defaultExtractPersistedOperationId,
2018
2027
  ...configContext,
2019
- ...config.persistedDocuments
2028
+ ...config.persistedDocuments,
2029
+ allowArbitraryOperations: allowArbitraryDocumentsForPersistedDocuments
2020
2030
  });
2021
2031
  persistedDocumentsPlugin = plugin;
2022
2032
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-hive/gateway-runtime",
3
- "version": "2.1.1",
3
+ "version": "2.1.2-alpha-deebbdd6955e1018f8702ddf86ee8da5c9cca8e7",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",