@graphql-tools/batch-delegate 10.0.23 → 10.0.24-rc-8a13ce71a0e8f58bfb291d30e79cd42e96a06972

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-tools/batch-delegate
2
2
 
3
+ ## 10.0.24-rc-8a13ce71a0e8f58bfb291d30e79cd42e96a06972
4
+ ### Patch Changes
5
+
6
+
7
+
8
+ - [#2393](https://github.com/graphql-hive/gateway/pull/2393) [`b6230c9`](https://github.com/graphql-hive/gateway/commit/b6230c97709065c2f540b6d263af492379eca359) Thanks [@sjransom](https://github.com/sjransom)! - Fix `DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array` thrown when the batch resolves to a sparse array.
9
+
10
+ When `valuesFromResults` returns an array with a hole at the trailing slot — for example when it maps results back to keys by index and the last key in a batch has no matching row — the resulting array fails DataLoader's `isArrayLike` check (which requires `hasOwnProperty(length - 1)`), even though `Array.isArray` returns `true`. The batch result is now normalised to a dense array of `keys.length`, padding any missing entries with `null`.
11
+
3
12
  ## 10.0.23
4
13
  ### Patch Changes
5
14
 
package/dist/index.cjs CHANGED
@@ -40,7 +40,14 @@ function createBatchFn(options) {
40
40
  })
41
41
  ).then((results) => {
42
42
  const values = valuesFromResults == null ? results : results instanceof Error ? keys.map(() => results) : valuesFromResults(results, keys);
43
- return Array.isArray(values) ? values : keys.map(() => values);
43
+ if (!Array.isArray(values)) {
44
+ return keys.map(() => values);
45
+ }
46
+ const dense = new Array(keys.length);
47
+ for (let i = 0; i < keys.length; i++) {
48
+ dense[i] = values[i] ?? null;
49
+ }
50
+ return dense;
44
51
  }).catch((error) => keys.map(() => error));
45
52
  };
46
53
  }
package/dist/index.js CHANGED
@@ -34,7 +34,14 @@ function createBatchFn(options) {
34
34
  })
35
35
  ).then((results) => {
36
36
  const values = valuesFromResults == null ? results : results instanceof Error ? keys.map(() => results) : valuesFromResults(results, keys);
37
- return Array.isArray(values) ? values : keys.map(() => values);
37
+ if (!Array.isArray(values)) {
38
+ return keys.map(() => values);
39
+ }
40
+ const dense = new Array(keys.length);
41
+ for (let i = 0; i < keys.length; i++) {
42
+ dense[i] = values[i] ?? null;
43
+ }
44
+ return dense;
38
45
  }).catch((error) => keys.map(() => error));
39
46
  };
40
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/batch-delegate",
3
- "version": "10.0.23",
3
+ "version": "10.0.24-rc-8a13ce71a0e8f58bfb291d30e79cd42e96a06972",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {