@graphql-tools/federation 4.1.0 → 4.2.0-alpha-ac3de4fa8e8de4ff5669df7e4225fa19cba4c2f7

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,29 @@
1
1
  # @graphql-tools/federation
2
2
 
3
+ ## 4.2.0-alpha-ac3de4fa8e8de4ff5669df7e4225fa19cba4c2f7
4
+ ### Minor Changes
5
+
6
+
7
+
8
+ - [#1642](https://github.com/graphql-hive/gateway/pull/1642) [`ac3de4f`](https://github.com/graphql-hive/gateway/commit/ac3de4fa8e8de4ff5669df7e4225fa19cba4c2f7) Thanks [@ardatan](https://github.com/ardatan)! - Support promises in `progressiveOverride` option
9
+
10
+ ```ts
11
+ defineConfig({
12
+ async progressiveOverride(label: string, context: GatewayContext) {
13
+ if (label === 'my_label') {
14
+ const serviceResponse = await fetch('http://example.com/should_override', {
15
+ headers: {
16
+ 'x-some-header': context.headers['x-some-header'],
17
+ }
18
+ });
19
+ const result = await serviceResponse.json();
20
+ return result?.override;
21
+ }
22
+ return false;
23
+ }
24
+ })
25
+ ```
26
+
3
27
  ## 4.1.0
4
28
  ### Minor Changes
5
29
 
package/dist/index.cjs CHANGED
@@ -279,6 +279,7 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
279
279
  const orphanTypeMap = /* @__PURE__ */ new Map();
280
280
  const typeFieldASTMap = /* @__PURE__ */ new Map();
281
281
  const progressiveOverrideInfos = /* @__PURE__ */ new Map();
282
+ const overrideLabels = /* @__PURE__ */ new Set();
282
283
  for (const definition of supergraphAst.definitions) {
283
284
  if ("fields" in definition) {
284
285
  const fieldMap = /* @__PURE__ */ new Map();
@@ -460,6 +461,7 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
460
461
  from: overrideFromSubgraph,
461
462
  label: overrideLabel
462
463
  });
464
+ overrideLabels.add(overrideLabel);
463
465
  }
464
466
  const providedExtraField = joinFieldDirectiveNode.arguments?.find(
465
467
  (argumentNode) => argumentNode.name.value === "provides"
@@ -1505,6 +1507,15 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1505
1507
  opts.onSubschemaConfig(subschema);
1506
1508
  }
1507
1509
  }
1510
+ let schemaExtensions;
1511
+ if (overrideLabels.size) {
1512
+ schemaExtensions = {
1513
+ schemaExtensions: {
1514
+ overrideLabels
1515
+ },
1516
+ types: {}
1517
+ };
1518
+ }
1508
1519
  return {
1509
1520
  subschemas,
1510
1521
  typeDefs: additionalTypeDefs,
@@ -1516,7 +1527,8 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1516
1527
  validationLevel: stitch.ValidationLevel.Off
1517
1528
  },
1518
1529
  fieldConfigMerger
1519
- }
1530
+ },
1531
+ schemaExtensions
1520
1532
  };
1521
1533
  }
1522
1534
  function getStitchedSchemaFromSupergraphSdl(opts) {
package/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@ import * as graphql from 'graphql';
6
6
  import { SelectionSetNode, GraphQLSchema, TypeNode, DocumentNode } from 'graphql';
7
7
  import { SubschemaConfig, MergedTypeConfig, BatchingOptions } from '@graphql-tools/delegate';
8
8
  import { ValidationLevel, MergeFieldConfigCandidate } from '@graphql-tools/stitch';
9
- import { Executor } from '@graphql-tools/utils';
9
+ import { Executor, SchemaExtensions } from '@graphql-tools/utils';
10
10
  import { GraphQLResolveInfo } from 'graphql/type';
11
11
 
12
12
  declare const getArgsFromKeysForFederation: (representations: readonly any[]) => {
@@ -69,6 +69,7 @@ declare function getStitchingOptionsFromSupergraphSdl(opts: GetStitchingOptionsF
69
69
  };
70
70
  fieldConfigMerger: (candidates: MergeFieldConfigCandidate<Record<string, any>>[]) => graphql.GraphQLFieldConfig<any, Record<string, any>, any>;
71
71
  };
72
+ schemaExtensions: SchemaExtensions | undefined;
72
73
  };
73
74
  interface GetStitchedSchemaFromSupergraphSdlOpts extends GetStitchingOptionsFromSupergraphSdlOpts {
74
75
  supergraphSdl: string | DocumentNode;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ import * as graphql from 'graphql';
6
6
  import { SelectionSetNode, GraphQLSchema, TypeNode, DocumentNode } from 'graphql';
7
7
  import { SubschemaConfig, MergedTypeConfig, BatchingOptions } from '@graphql-tools/delegate';
8
8
  import { ValidationLevel, MergeFieldConfigCandidate } from '@graphql-tools/stitch';
9
- import { Executor } from '@graphql-tools/utils';
9
+ import { Executor, SchemaExtensions } from '@graphql-tools/utils';
10
10
  import { GraphQLResolveInfo } from 'graphql/type';
11
11
 
12
12
  declare const getArgsFromKeysForFederation: (representations: readonly any[]) => {
@@ -69,6 +69,7 @@ declare function getStitchingOptionsFromSupergraphSdl(opts: GetStitchingOptionsF
69
69
  };
70
70
  fieldConfigMerger: (candidates: MergeFieldConfigCandidate<Record<string, any>>[]) => graphql.GraphQLFieldConfig<any, Record<string, any>, any>;
71
71
  };
72
+ schemaExtensions: SchemaExtensions | undefined;
72
73
  };
73
74
  interface GetStitchedSchemaFromSupergraphSdlOpts extends GetStitchingOptionsFromSupergraphSdlOpts {
74
75
  supergraphSdl: string | DocumentNode;
package/dist/index.js CHANGED
@@ -277,6 +277,7 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
277
277
  const orphanTypeMap = /* @__PURE__ */ new Map();
278
278
  const typeFieldASTMap = /* @__PURE__ */ new Map();
279
279
  const progressiveOverrideInfos = /* @__PURE__ */ new Map();
280
+ const overrideLabels = /* @__PURE__ */ new Set();
280
281
  for (const definition of supergraphAst.definitions) {
281
282
  if ("fields" in definition) {
282
283
  const fieldMap = /* @__PURE__ */ new Map();
@@ -458,6 +459,7 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
458
459
  from: overrideFromSubgraph,
459
460
  label: overrideLabel
460
461
  });
462
+ overrideLabels.add(overrideLabel);
461
463
  }
462
464
  const providedExtraField = joinFieldDirectiveNode.arguments?.find(
463
465
  (argumentNode) => argumentNode.name.value === "provides"
@@ -1503,6 +1505,15 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1503
1505
  opts.onSubschemaConfig(subschema);
1504
1506
  }
1505
1507
  }
1508
+ let schemaExtensions;
1509
+ if (overrideLabels.size) {
1510
+ schemaExtensions = {
1511
+ schemaExtensions: {
1512
+ overrideLabels
1513
+ },
1514
+ types: {}
1515
+ };
1516
+ }
1506
1517
  return {
1507
1518
  subschemas,
1508
1519
  typeDefs: additionalTypeDefs,
@@ -1514,7 +1525,8 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
1514
1525
  validationLevel: ValidationLevel.Off
1515
1526
  },
1516
1527
  fieldConfigMerger
1517
- }
1528
+ },
1529
+ schemaExtensions
1518
1530
  };
1519
1531
  }
1520
1532
  function getStitchedSchemaFromSupergraphSdl(opts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/federation",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-alpha-ac3de4fa8e8de4ff5669df7e4225fa19cba4c2f7",
4
4
  "type": "module",
5
5
  "description": "Useful tools to create and manipulate GraphQL schemas.",
6
6
  "repository": {