@graphql-tools/federation 4.2.9 → 4.2.10-alpha-5aa2a8cb6ef1d254393e7926d9b26759d3df4901
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 +11 -0
- package/dist/index.cjs +145 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +145 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @graphql-tools/federation
|
|
2
2
|
|
|
3
|
+
## 4.2.10-alpha-5aa2a8cb6ef1d254393e7926d9b26759d3df4901
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1916](https://github.com/graphql-hive/gateway/pull/1916) [`5aa2a8c`](https://github.com/graphql-hive/gateway/commit/5aa2a8cb6ef1d254393e7926d9b26759d3df4901) Thanks [@ardatan](https://github.com/ardatan)! - Do not pass `percent(x)` labels to the progressive override handler
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
- [#1916](https://github.com/graphql-hive/gateway/pull/1916) [`5aa2a8c`](https://github.com/graphql-hive/gateway/commit/5aa2a8cb6ef1d254393e7926d9b26759d3df4901) Thanks [@ardatan](https://github.com/ardatan)! - Handle the type merging order correctly with custom labels and percentage labels for progressive override
|
|
13
|
+
|
|
3
14
|
## 4.2.9
|
|
4
15
|
### Patch Changes
|
|
5
16
|
|
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,92 @@ function getEnvStr(key, opts = {}) {
|
|
|
25
25
|
return variable?.trim();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// Regexps involved with splitting words in various case formats.
|
|
29
|
+
const SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
30
|
+
const SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
31
|
+
// Used to iterate over the initial split result and separate numbers.
|
|
32
|
+
const SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
33
|
+
// Regexp involved with stripping non-word characters from the result.
|
|
34
|
+
const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
35
|
+
// The replacement value for splits.
|
|
36
|
+
const SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
37
|
+
// The default characters to keep after transforming case.
|
|
38
|
+
const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
39
|
+
/**
|
|
40
|
+
* Split any cased input strings into an array of words.
|
|
41
|
+
*/
|
|
42
|
+
function split(value) {
|
|
43
|
+
let result = value.trim();
|
|
44
|
+
result = result
|
|
45
|
+
.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)
|
|
46
|
+
.replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
47
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
48
|
+
let start = 0;
|
|
49
|
+
let end = result.length;
|
|
50
|
+
// Trim the delimiter from around the output string.
|
|
51
|
+
while (result.charAt(start) === "\0")
|
|
52
|
+
start++;
|
|
53
|
+
if (start === end)
|
|
54
|
+
return [];
|
|
55
|
+
while (result.charAt(end - 1) === "\0")
|
|
56
|
+
end--;
|
|
57
|
+
return result.slice(start, end).split(/\0/g);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Split the input string into an array of words, separating numbers.
|
|
61
|
+
*/
|
|
62
|
+
function splitSeparateNumbers(value) {
|
|
63
|
+
const words = split(value);
|
|
64
|
+
for (let i = 0; i < words.length; i++) {
|
|
65
|
+
const word = words[i];
|
|
66
|
+
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
67
|
+
if (match) {
|
|
68
|
+
const offset = match.index + (match[1] ?? match[2]).length;
|
|
69
|
+
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return words;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Convert a string to constant case (`FOO_BAR`).
|
|
76
|
+
*/
|
|
77
|
+
function constantCase(input, options) {
|
|
78
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
79
|
+
return (prefix +
|
|
80
|
+
words.map(upperFactory(options?.locale)).join("_") +
|
|
81
|
+
suffix);
|
|
82
|
+
}
|
|
83
|
+
function upperFactory(locale) {
|
|
84
|
+
return locale === false
|
|
85
|
+
? (input) => input.toUpperCase()
|
|
86
|
+
: (input) => input.toLocaleUpperCase(locale);
|
|
87
|
+
}
|
|
88
|
+
function splitPrefixSuffix(input, options = {}) {
|
|
89
|
+
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
90
|
+
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
91
|
+
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
92
|
+
let prefixIndex = 0;
|
|
93
|
+
let suffixIndex = input.length;
|
|
94
|
+
while (prefixIndex < input.length) {
|
|
95
|
+
const char = input.charAt(prefixIndex);
|
|
96
|
+
if (!prefixCharacters.includes(char))
|
|
97
|
+
break;
|
|
98
|
+
prefixIndex++;
|
|
99
|
+
}
|
|
100
|
+
while (suffixIndex > prefixIndex) {
|
|
101
|
+
const index = suffixIndex - 1;
|
|
102
|
+
const char = input.charAt(index);
|
|
103
|
+
if (!suffixCharacters.includes(char))
|
|
104
|
+
break;
|
|
105
|
+
suffixIndex = index;
|
|
106
|
+
}
|
|
107
|
+
return [
|
|
108
|
+
input.slice(0, prefixIndex),
|
|
109
|
+
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
110
|
+
input.slice(suffixIndex),
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
|
|
28
114
|
const getArgsFromKeysForFederation = utils.memoize1(
|
|
29
115
|
function getArgsFromKeysForFederation2(representations) {
|
|
30
116
|
return { representations };
|
|
@@ -279,6 +365,7 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
|
|
|
279
365
|
const orphanTypeMap = /* @__PURE__ */ new Map();
|
|
280
366
|
const typeFieldASTMap = /* @__PURE__ */ new Map();
|
|
281
367
|
const progressiveOverrideInfos = /* @__PURE__ */ new Map();
|
|
368
|
+
const progressiveOverrideInfosOpposite = /* @__PURE__ */ new Map();
|
|
282
369
|
const overrideLabels = /* @__PURE__ */ new Set();
|
|
283
370
|
for (const definition of supergraphAst.definitions) {
|
|
284
371
|
if ("fields" in definition) {
|
|
@@ -461,7 +548,33 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
|
|
|
461
548
|
from: overrideFromSubgraph,
|
|
462
549
|
label: overrideLabel
|
|
463
550
|
});
|
|
464
|
-
|
|
551
|
+
if (!overrideLabel.startsWith("percent(")) {
|
|
552
|
+
overrideLabels.add(overrideLabel);
|
|
553
|
+
}
|
|
554
|
+
const oppositeKey = constantCase(overrideFromSubgraph);
|
|
555
|
+
let oppositeInfos = progressiveOverrideInfosOpposite.get(oppositeKey);
|
|
556
|
+
if (!oppositeInfos) {
|
|
557
|
+
oppositeInfos = /* @__PURE__ */ new Map();
|
|
558
|
+
progressiveOverrideInfosOpposite.set(
|
|
559
|
+
oppositeKey,
|
|
560
|
+
oppositeInfos
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
let existingOppositeInfos = oppositeInfos.get(
|
|
564
|
+
typeNode.name.value
|
|
565
|
+
);
|
|
566
|
+
if (!existingOppositeInfos) {
|
|
567
|
+
existingOppositeInfos = [];
|
|
568
|
+
oppositeInfos.set(
|
|
569
|
+
typeNode.name.value,
|
|
570
|
+
existingOppositeInfos
|
|
571
|
+
);
|
|
572
|
+
}
|
|
573
|
+
existingOppositeInfos.push({
|
|
574
|
+
field: fieldNode.name.value,
|
|
575
|
+
to: graphName,
|
|
576
|
+
label: overrideLabel
|
|
577
|
+
});
|
|
465
578
|
}
|
|
466
579
|
const providedExtraField = joinFieldDirectiveNode.arguments?.find(
|
|
467
580
|
(argumentNode) => argumentNode.name.value === "provides"
|
|
@@ -1239,6 +1352,37 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
|
|
|
1239
1352
|
}
|
|
1240
1353
|
}
|
|
1241
1354
|
}
|
|
1355
|
+
const progressiveOverrideOppositeInfosForSubgraph = progressiveOverrideInfosOpposite.get(constantCase(subgraphName));
|
|
1356
|
+
if (progressiveOverrideOppositeInfosForSubgraph != null) {
|
|
1357
|
+
for (const [
|
|
1358
|
+
typeName,
|
|
1359
|
+
fieldInfos
|
|
1360
|
+
] of progressiveOverrideOppositeInfosForSubgraph) {
|
|
1361
|
+
let mergedConfig = mergeConfig[typeName];
|
|
1362
|
+
if (!mergedConfig) {
|
|
1363
|
+
mergedConfig = mergeConfig[typeName] = {};
|
|
1364
|
+
}
|
|
1365
|
+
for (const fieldInfo of fieldInfos) {
|
|
1366
|
+
let fieldsConfig = mergedConfig.fields;
|
|
1367
|
+
if (!fieldsConfig) {
|
|
1368
|
+
fieldsConfig = mergedConfig.fields = {};
|
|
1369
|
+
}
|
|
1370
|
+
let fieldConfig = fieldsConfig[fieldInfo.field];
|
|
1371
|
+
if (!fieldConfig) {
|
|
1372
|
+
fieldConfig = fieldsConfig[fieldInfo.field] = {};
|
|
1373
|
+
}
|
|
1374
|
+
const label = fieldInfo.label;
|
|
1375
|
+
const percent = extractPercentageFromLabel(label);
|
|
1376
|
+
if (percent != null) {
|
|
1377
|
+
const possibility = percent / 100;
|
|
1378
|
+
fieldConfig.override = () => !progressiveOverridePossibilityHandler(possibility);
|
|
1379
|
+
} else if (opts.handleProgressiveOverride) {
|
|
1380
|
+
const progressiveOverrideHandler = opts.handleProgressiveOverride;
|
|
1381
|
+
fieldConfig.override = (context, info) => !progressiveOverrideHandler(label, context, info);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1242
1386
|
const subschemaConfig = {
|
|
1243
1387
|
name: subgraphName,
|
|
1244
1388
|
endpoint,
|
package/dist/index.d.cts
CHANGED
|
@@ -57,6 +57,11 @@ interface ProgressiveOverrideInfo {
|
|
|
57
57
|
from: string;
|
|
58
58
|
label: string;
|
|
59
59
|
}
|
|
60
|
+
interface ProgressiveOverrideInfoOpposite {
|
|
61
|
+
field: string;
|
|
62
|
+
to: string;
|
|
63
|
+
label: string;
|
|
64
|
+
}
|
|
60
65
|
declare function getStitchingOptionsFromSupergraphSdl(opts: GetStitchingOptionsFromSupergraphSdlOpts): {
|
|
61
66
|
subschemas: SubschemaConfig<any, any, any, Record<string, any>>[];
|
|
62
67
|
typeDefs: DocumentNode;
|
|
@@ -242,4 +247,4 @@ declare class SupergraphSchemaManager extends TypedEventTargetCtor<SupergraphSch
|
|
|
242
247
|
[DisposableSymbols.dispose](): Promise<void>;
|
|
243
248
|
}
|
|
244
249
|
|
|
245
|
-
export { DEFAULT_UPLINKS, type FederationSubschemaConfig, type FetchError, type FetchSupergraphSdlFromManagedFederationOpts, type GetStitchedSchemaFromManagedFederationOpts, type GetStitchedSchemaFromSupergraphSdlOpts, type GetStitchingOptionsFromSupergraphSdlOpts, type ProgressiveOverrideHandler, type ProgressiveOverrideInfo, type RouterConfig, type RouterConfigWithSchema, SupergraphSchemaManager, type SupergraphSchemaManagerErrorEvent, type SupergraphSchemaManagerEvent, type SupergraphSchemaManagerFailureEvent, type SupergraphSchemaManagerLogEvent, type SupergraphSchemaManagerOptions, type SupergraphSchemaManagerSchemaEvent, type Unchanged, ensureSupergraphSDLAst, extractPercentageFromLabel, fetchSupergraphSdlFromManagedFederation, filterInternalFieldsAndTypes, getArgsFromKeysForFederation, getCacheKeyFnFromKey, getKeyFnForFederation, getNamedTypeNode, getStitchedSchemaFromManagedFederation, getStitchedSchemaFromSupergraphSdl, getStitchingOptionsFromSupergraphSdl, progressiveOverridePossibilityHandler, projectDataSelectionSet };
|
|
250
|
+
export { DEFAULT_UPLINKS, type FederationSubschemaConfig, type FetchError, type FetchSupergraphSdlFromManagedFederationOpts, type GetStitchedSchemaFromManagedFederationOpts, type GetStitchedSchemaFromSupergraphSdlOpts, type GetStitchingOptionsFromSupergraphSdlOpts, type ProgressiveOverrideHandler, type ProgressiveOverrideInfo, type ProgressiveOverrideInfoOpposite, type RouterConfig, type RouterConfigWithSchema, SupergraphSchemaManager, type SupergraphSchemaManagerErrorEvent, type SupergraphSchemaManagerEvent, type SupergraphSchemaManagerFailureEvent, type SupergraphSchemaManagerLogEvent, type SupergraphSchemaManagerOptions, type SupergraphSchemaManagerSchemaEvent, type Unchanged, ensureSupergraphSDLAst, extractPercentageFromLabel, fetchSupergraphSdlFromManagedFederation, filterInternalFieldsAndTypes, getArgsFromKeysForFederation, getCacheKeyFnFromKey, getKeyFnForFederation, getNamedTypeNode, getStitchedSchemaFromManagedFederation, getStitchedSchemaFromSupergraphSdl, getStitchingOptionsFromSupergraphSdl, progressiveOverridePossibilityHandler, projectDataSelectionSet };
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,11 @@ interface ProgressiveOverrideInfo {
|
|
|
57
57
|
from: string;
|
|
58
58
|
label: string;
|
|
59
59
|
}
|
|
60
|
+
interface ProgressiveOverrideInfoOpposite {
|
|
61
|
+
field: string;
|
|
62
|
+
to: string;
|
|
63
|
+
label: string;
|
|
64
|
+
}
|
|
60
65
|
declare function getStitchingOptionsFromSupergraphSdl(opts: GetStitchingOptionsFromSupergraphSdlOpts): {
|
|
61
66
|
subschemas: SubschemaConfig<any, any, any, Record<string, any>>[];
|
|
62
67
|
typeDefs: DocumentNode;
|
|
@@ -242,4 +247,4 @@ declare class SupergraphSchemaManager extends TypedEventTargetCtor<SupergraphSch
|
|
|
242
247
|
[DisposableSymbols.dispose](): Promise<void>;
|
|
243
248
|
}
|
|
244
249
|
|
|
245
|
-
export { DEFAULT_UPLINKS, type FederationSubschemaConfig, type FetchError, type FetchSupergraphSdlFromManagedFederationOpts, type GetStitchedSchemaFromManagedFederationOpts, type GetStitchedSchemaFromSupergraphSdlOpts, type GetStitchingOptionsFromSupergraphSdlOpts, type ProgressiveOverrideHandler, type ProgressiveOverrideInfo, type RouterConfig, type RouterConfigWithSchema, SupergraphSchemaManager, type SupergraphSchemaManagerErrorEvent, type SupergraphSchemaManagerEvent, type SupergraphSchemaManagerFailureEvent, type SupergraphSchemaManagerLogEvent, type SupergraphSchemaManagerOptions, type SupergraphSchemaManagerSchemaEvent, type Unchanged, ensureSupergraphSDLAst, extractPercentageFromLabel, fetchSupergraphSdlFromManagedFederation, filterInternalFieldsAndTypes, getArgsFromKeysForFederation, getCacheKeyFnFromKey, getKeyFnForFederation, getNamedTypeNode, getStitchedSchemaFromManagedFederation, getStitchedSchemaFromSupergraphSdl, getStitchingOptionsFromSupergraphSdl, progressiveOverridePossibilityHandler, projectDataSelectionSet };
|
|
250
|
+
export { DEFAULT_UPLINKS, type FederationSubschemaConfig, type FetchError, type FetchSupergraphSdlFromManagedFederationOpts, type GetStitchedSchemaFromManagedFederationOpts, type GetStitchedSchemaFromSupergraphSdlOpts, type GetStitchingOptionsFromSupergraphSdlOpts, type ProgressiveOverrideHandler, type ProgressiveOverrideInfo, type ProgressiveOverrideInfoOpposite, type RouterConfig, type RouterConfigWithSchema, SupergraphSchemaManager, type SupergraphSchemaManagerErrorEvent, type SupergraphSchemaManagerEvent, type SupergraphSchemaManagerFailureEvent, type SupergraphSchemaManagerLogEvent, type SupergraphSchemaManagerOptions, type SupergraphSchemaManagerSchemaEvent, type Unchanged, ensureSupergraphSDLAst, extractPercentageFromLabel, fetchSupergraphSdlFromManagedFederation, filterInternalFieldsAndTypes, getArgsFromKeysForFederation, getCacheKeyFnFromKey, getKeyFnForFederation, getNamedTypeNode, getStitchedSchemaFromManagedFederation, getStitchedSchemaFromSupergraphSdl, getStitchingOptionsFromSupergraphSdl, progressiveOverridePossibilityHandler, projectDataSelectionSet };
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,92 @@ function getEnvStr(key, opts = {}) {
|
|
|
23
23
|
return variable?.trim();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
// Regexps involved with splitting words in various case formats.
|
|
27
|
+
const SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
28
|
+
const SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
29
|
+
// Used to iterate over the initial split result and separate numbers.
|
|
30
|
+
const SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
31
|
+
// Regexp involved with stripping non-word characters from the result.
|
|
32
|
+
const DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
33
|
+
// The replacement value for splits.
|
|
34
|
+
const SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
35
|
+
// The default characters to keep after transforming case.
|
|
36
|
+
const DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
37
|
+
/**
|
|
38
|
+
* Split any cased input strings into an array of words.
|
|
39
|
+
*/
|
|
40
|
+
function split(value) {
|
|
41
|
+
let result = value.trim();
|
|
42
|
+
result = result
|
|
43
|
+
.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE)
|
|
44
|
+
.replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
45
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
46
|
+
let start = 0;
|
|
47
|
+
let end = result.length;
|
|
48
|
+
// Trim the delimiter from around the output string.
|
|
49
|
+
while (result.charAt(start) === "\0")
|
|
50
|
+
start++;
|
|
51
|
+
if (start === end)
|
|
52
|
+
return [];
|
|
53
|
+
while (result.charAt(end - 1) === "\0")
|
|
54
|
+
end--;
|
|
55
|
+
return result.slice(start, end).split(/\0/g);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Split the input string into an array of words, separating numbers.
|
|
59
|
+
*/
|
|
60
|
+
function splitSeparateNumbers(value) {
|
|
61
|
+
const words = split(value);
|
|
62
|
+
for (let i = 0; i < words.length; i++) {
|
|
63
|
+
const word = words[i];
|
|
64
|
+
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
65
|
+
if (match) {
|
|
66
|
+
const offset = match.index + (match[1] ?? match[2]).length;
|
|
67
|
+
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return words;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Convert a string to constant case (`FOO_BAR`).
|
|
74
|
+
*/
|
|
75
|
+
function constantCase(input, options) {
|
|
76
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
77
|
+
return (prefix +
|
|
78
|
+
words.map(upperFactory(options?.locale)).join("_") +
|
|
79
|
+
suffix);
|
|
80
|
+
}
|
|
81
|
+
function upperFactory(locale) {
|
|
82
|
+
return locale === false
|
|
83
|
+
? (input) => input.toUpperCase()
|
|
84
|
+
: (input) => input.toLocaleUpperCase(locale);
|
|
85
|
+
}
|
|
86
|
+
function splitPrefixSuffix(input, options = {}) {
|
|
87
|
+
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
88
|
+
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
89
|
+
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
90
|
+
let prefixIndex = 0;
|
|
91
|
+
let suffixIndex = input.length;
|
|
92
|
+
while (prefixIndex < input.length) {
|
|
93
|
+
const char = input.charAt(prefixIndex);
|
|
94
|
+
if (!prefixCharacters.includes(char))
|
|
95
|
+
break;
|
|
96
|
+
prefixIndex++;
|
|
97
|
+
}
|
|
98
|
+
while (suffixIndex > prefixIndex) {
|
|
99
|
+
const index = suffixIndex - 1;
|
|
100
|
+
const char = input.charAt(index);
|
|
101
|
+
if (!suffixCharacters.includes(char))
|
|
102
|
+
break;
|
|
103
|
+
suffixIndex = index;
|
|
104
|
+
}
|
|
105
|
+
return [
|
|
106
|
+
input.slice(0, prefixIndex),
|
|
107
|
+
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
108
|
+
input.slice(suffixIndex),
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
26
112
|
const getArgsFromKeysForFederation = memoize1(
|
|
27
113
|
function getArgsFromKeysForFederation2(representations) {
|
|
28
114
|
return { representations };
|
|
@@ -277,6 +363,7 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
|
|
|
277
363
|
const orphanTypeMap = /* @__PURE__ */ new Map();
|
|
278
364
|
const typeFieldASTMap = /* @__PURE__ */ new Map();
|
|
279
365
|
const progressiveOverrideInfos = /* @__PURE__ */ new Map();
|
|
366
|
+
const progressiveOverrideInfosOpposite = /* @__PURE__ */ new Map();
|
|
280
367
|
const overrideLabels = /* @__PURE__ */ new Set();
|
|
281
368
|
for (const definition of supergraphAst.definitions) {
|
|
282
369
|
if ("fields" in definition) {
|
|
@@ -459,7 +546,33 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
|
|
|
459
546
|
from: overrideFromSubgraph,
|
|
460
547
|
label: overrideLabel
|
|
461
548
|
});
|
|
462
|
-
|
|
549
|
+
if (!overrideLabel.startsWith("percent(")) {
|
|
550
|
+
overrideLabels.add(overrideLabel);
|
|
551
|
+
}
|
|
552
|
+
const oppositeKey = constantCase(overrideFromSubgraph);
|
|
553
|
+
let oppositeInfos = progressiveOverrideInfosOpposite.get(oppositeKey);
|
|
554
|
+
if (!oppositeInfos) {
|
|
555
|
+
oppositeInfos = /* @__PURE__ */ new Map();
|
|
556
|
+
progressiveOverrideInfosOpposite.set(
|
|
557
|
+
oppositeKey,
|
|
558
|
+
oppositeInfos
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
let existingOppositeInfos = oppositeInfos.get(
|
|
562
|
+
typeNode.name.value
|
|
563
|
+
);
|
|
564
|
+
if (!existingOppositeInfos) {
|
|
565
|
+
existingOppositeInfos = [];
|
|
566
|
+
oppositeInfos.set(
|
|
567
|
+
typeNode.name.value,
|
|
568
|
+
existingOppositeInfos
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
existingOppositeInfos.push({
|
|
572
|
+
field: fieldNode.name.value,
|
|
573
|
+
to: graphName,
|
|
574
|
+
label: overrideLabel
|
|
575
|
+
});
|
|
463
576
|
}
|
|
464
577
|
const providedExtraField = joinFieldDirectiveNode.arguments?.find(
|
|
465
578
|
(argumentNode) => argumentNode.name.value === "provides"
|
|
@@ -1237,6 +1350,37 @@ function getStitchingOptionsFromSupergraphSdl(opts) {
|
|
|
1237
1350
|
}
|
|
1238
1351
|
}
|
|
1239
1352
|
}
|
|
1353
|
+
const progressiveOverrideOppositeInfosForSubgraph = progressiveOverrideInfosOpposite.get(constantCase(subgraphName));
|
|
1354
|
+
if (progressiveOverrideOppositeInfosForSubgraph != null) {
|
|
1355
|
+
for (const [
|
|
1356
|
+
typeName,
|
|
1357
|
+
fieldInfos
|
|
1358
|
+
] of progressiveOverrideOppositeInfosForSubgraph) {
|
|
1359
|
+
let mergedConfig = mergeConfig[typeName];
|
|
1360
|
+
if (!mergedConfig) {
|
|
1361
|
+
mergedConfig = mergeConfig[typeName] = {};
|
|
1362
|
+
}
|
|
1363
|
+
for (const fieldInfo of fieldInfos) {
|
|
1364
|
+
let fieldsConfig = mergedConfig.fields;
|
|
1365
|
+
if (!fieldsConfig) {
|
|
1366
|
+
fieldsConfig = mergedConfig.fields = {};
|
|
1367
|
+
}
|
|
1368
|
+
let fieldConfig = fieldsConfig[fieldInfo.field];
|
|
1369
|
+
if (!fieldConfig) {
|
|
1370
|
+
fieldConfig = fieldsConfig[fieldInfo.field] = {};
|
|
1371
|
+
}
|
|
1372
|
+
const label = fieldInfo.label;
|
|
1373
|
+
const percent = extractPercentageFromLabel(label);
|
|
1374
|
+
if (percent != null) {
|
|
1375
|
+
const possibility = percent / 100;
|
|
1376
|
+
fieldConfig.override = () => !progressiveOverridePossibilityHandler(possibility);
|
|
1377
|
+
} else if (opts.handleProgressiveOverride) {
|
|
1378
|
+
const progressiveOverrideHandler = opts.handleProgressiveOverride;
|
|
1379
|
+
fieldConfig.override = (context, info) => !progressiveOverrideHandler(label, context, info);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1240
1384
|
const subschemaConfig = {
|
|
1241
1385
|
name: subgraphName,
|
|
1242
1386
|
endpoint,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/federation",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.10-alpha-5aa2a8cb6ef1d254393e7926d9b26759d3df4901",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Useful tools to create and manipulate GraphQL schemas.",
|
|
6
6
|
"repository": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@apollo/server-gateway-interface": "^2.0.0",
|
|
60
60
|
"@apollo/subgraph": "^2.11.3",
|
|
61
61
|
"@types/lodash": "4.17.23",
|
|
62
|
+
"change-case": "^5.4.4",
|
|
62
63
|
"graphql": "^16.12.0",
|
|
63
64
|
"graphql-federation-gateway-audit": "graphql-hive/federation-gateway-audit#cc224d26da54ad1c2393dfef3346893c315f351d",
|
|
64
65
|
"pkgroll": "2.23.0"
|