@graphql-tools/federation 3.2.9 → 3.2.10-alpha-ca72727f03d744399b898bc79a032554428dcdb9

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,15 @@
1
1
  # @graphql-tools/federation
2
2
 
3
+ ## 3.2.10-alpha-ca72727f03d744399b898bc79a032554428dcdb9
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#1419](https://github.com/graphql-hive/gateway/pull/1419) [`ca72727`](https://github.com/graphql-hive/gateway/commit/ca72727f03d744399b898bc79a032554428dcdb9) Thanks [@ardatan](https://github.com/ardatan)! - Inflight request deduplication
9
+
10
+ - Updated dependencies [[`ca72727`](https://github.com/graphql-hive/gateway/commit/ca72727f03d744399b898bc79a032554428dcdb9)]:
11
+ - @graphql-tools/executor-http@2.1.3-alpha-ca72727f03d744399b898bc79a032554428dcdb9
12
+
3
13
  ## 3.2.9
4
14
  ### Patch Changes
5
15
 
package/dist/index.cjs CHANGED
@@ -103,9 +103,9 @@ function getKeyFnForFederation(typeName, keys) {
103
103
  );
104
104
  };
105
105
  }
106
- const allKeyProps = keys.flatMap((key) => key.split(" ")).map((key) => key.trim());
106
+ const allKeyProps = keys.flatMap((key) => key.trim().split(" ")).map((key) => key.trim());
107
107
  if (allKeyProps.length > 1) {
108
- return function keyFn(root) {
108
+ return utils.memoize1(function keyFn(root) {
109
109
  if (root == null) {
110
110
  return null;
111
111
  }
@@ -118,7 +118,7 @@ function getKeyFnForFederation(typeName, keys) {
118
118
  },
119
119
  { __typename: typeName }
120
120
  );
121
- };
121
+ });
122
122
  }
123
123
  const keyProp = allKeyProps[0];
124
124
  return utils.memoize1(function keyFn(root) {
@@ -147,18 +147,26 @@ function getCacheKeyFnFromKey(key) {
147
147
  const keyTrimmed = key.trim();
148
148
  const keys = keyTrimmed.split(" ").map((key2) => key2.trim());
149
149
  if (keys.length > 1) {
150
- return function cacheKeyFn(root) {
151
- return keys.map((key2) => {
150
+ return utils.memoize1(function cacheKeyFn(root) {
151
+ let cacheKeyStr = "";
152
+ for (const key2 of keys) {
152
153
  const keyVal = root[key2];
153
154
  if (keyVal == null) {
154
- return "";
155
- }
156
- if (typeof keyVal === "object") {
157
- return JSON.stringify(keyVal);
155
+ continue;
156
+ } else if (typeof keyVal === "object") {
157
+ if (cacheKeyStr) {
158
+ cacheKeyStr += " ";
159
+ }
160
+ cacheKeyStr += JSON.stringify(keyVal);
161
+ } else {
162
+ if (cacheKeyStr) {
163
+ cacheKeyStr += " ";
164
+ }
165
+ cacheKeyStr += keyVal;
158
166
  }
159
- return keyVal;
160
- }).join(" ");
161
- };
167
+ }
168
+ return cacheKeyStr;
169
+ });
162
170
  }
163
171
  return utils.memoize1(function cacheKeyFn(root) {
164
172
  const keyVal = root[keyTrimmed];
package/dist/index.js CHANGED
@@ -101,9 +101,9 @@ function getKeyFnForFederation(typeName, keys) {
101
101
  );
102
102
  };
103
103
  }
104
- const allKeyProps = keys.flatMap((key) => key.split(" ")).map((key) => key.trim());
104
+ const allKeyProps = keys.flatMap((key) => key.trim().split(" ")).map((key) => key.trim());
105
105
  if (allKeyProps.length > 1) {
106
- return function keyFn(root) {
106
+ return memoize1(function keyFn(root) {
107
107
  if (root == null) {
108
108
  return null;
109
109
  }
@@ -116,7 +116,7 @@ function getKeyFnForFederation(typeName, keys) {
116
116
  },
117
117
  { __typename: typeName }
118
118
  );
119
- };
119
+ });
120
120
  }
121
121
  const keyProp = allKeyProps[0];
122
122
  return memoize1(function keyFn(root) {
@@ -145,18 +145,26 @@ function getCacheKeyFnFromKey(key) {
145
145
  const keyTrimmed = key.trim();
146
146
  const keys = keyTrimmed.split(" ").map((key2) => key2.trim());
147
147
  if (keys.length > 1) {
148
- return function cacheKeyFn(root) {
149
- return keys.map((key2) => {
148
+ return memoize1(function cacheKeyFn(root) {
149
+ let cacheKeyStr = "";
150
+ for (const key2 of keys) {
150
151
  const keyVal = root[key2];
151
152
  if (keyVal == null) {
152
- return "";
153
- }
154
- if (typeof keyVal === "object") {
155
- return JSON.stringify(keyVal);
153
+ continue;
154
+ } else if (typeof keyVal === "object") {
155
+ if (cacheKeyStr) {
156
+ cacheKeyStr += " ";
157
+ }
158
+ cacheKeyStr += JSON.stringify(keyVal);
159
+ } else {
160
+ if (cacheKeyStr) {
161
+ cacheKeyStr += " ";
162
+ }
163
+ cacheKeyStr += keyVal;
156
164
  }
157
- return keyVal;
158
- }).join(" ");
159
- };
165
+ }
166
+ return cacheKeyStr;
167
+ });
160
168
  }
161
169
  return memoize1(function cacheKeyFn(root) {
162
170
  const keyVal = root[keyTrimmed];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/federation",
3
- "version": "3.2.9",
3
+ "version": "3.2.10-alpha-ca72727f03d744399b898bc79a032554428dcdb9",
4
4
  "type": "module",
5
5
  "description": "Useful tools to create and manipulate GraphQL schemas.",
6
6
  "repository": {
@@ -40,10 +40,10 @@
40
40
  "dependencies": {
41
41
  "@graphql-tools/delegate": "^10.2.23",
42
42
  "@graphql-tools/executor": "^1.4.9",
43
- "@graphql-tools/executor-http": "^2.1.2",
43
+ "@graphql-tools/executor-http": "2.1.3-alpha-ca72727f03d744399b898bc79a032554428dcdb9",
44
44
  "@graphql-tools/merge": "^9.1.1",
45
45
  "@graphql-tools/schema": "^10.0.25",
46
- "@graphql-tools/stitch": "^9.4.28",
46
+ "@graphql-tools/stitch": "^9.4.29",
47
47
  "@graphql-tools/utils": "^10.9.1",
48
48
  "@graphql-tools/wrap": "^10.1.4",
49
49
  "@graphql-yoga/typed-event-target": "^3.0.2",