@graphql-tools/utils 10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d → 10.11.0-alpha-20251114142557-eae3c3166430d65945da6837f875fc7800cc1a26

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/cjs/errors.js CHANGED
@@ -44,12 +44,10 @@ function createGraphQLError(message, options) {
44
44
  ? new Constructor(message, options)
45
45
  : new Constructor(message, options?.nodes, options?.source, options?.positions, options?.path, options?.originalError, options?.extensions);
46
46
  if (options?.coordinate && error.coordinate == null) {
47
- Object.defineProperty(error, 'coordinate', {
48
- value: options.coordinate,
49
- enumerable: true,
50
- configurable: true,
47
+ Object.defineProperties(error, {
48
+ coordinate: { value: options.coordinate, enumerable: true, configurable: true },
49
+ toJSON: { value: exports.toJSON },
51
50
  });
52
- error.toJSON = exports.toJSON;
53
51
  }
54
52
  return error;
55
53
  }
@@ -59,9 +57,12 @@ function getSchemaCoordinate(error) {
59
57
  function locatedError(rawError, nodes, path, info) {
60
58
  const error = (0, graphql_1.locatedError)(rawError, nodes, path);
61
59
  // `graphql` locatedError is only changing path and nodes if it is not already defined
62
- if (!error.coordinate && info) {
63
- // @ts-expect-error coordinate is readonly, but we don't want to recreate it just to add coordinate
64
- error.coordinate = `${info.parentType.name}.${info.fieldName}`;
60
+ if (!error.coordinate && info && error.coordinate == null) {
61
+ const coordinate = `${info.parentType.name}.${info.fieldName}`;
62
+ Object.defineProperties(error, {
63
+ coordinate: { value: coordinate, enumerable: true, configurable: true },
64
+ toJSON: { value: exports.toJSON },
65
+ });
65
66
  }
66
67
  return error;
67
68
  }
@@ -1,25 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeIncrementalResult = mergeIncrementalResult;
4
- const merge_1 = require("dset/merge");
4
+ const mergeDeep_js_1 = require("./mergeDeep.js");
5
5
  function mergeIncrementalResult({ incrementalResult, executionResult, }) {
6
6
  const path = ['data', ...(incrementalResult.path ?? [])];
7
7
  if (incrementalResult.items) {
8
8
  for (const item of incrementalResult.items) {
9
- (0, merge_1.dset)(executionResult, path, item);
9
+ setObjectKeyPath(executionResult, path, item);
10
10
  // Increment the last path segment (the array index) to merge the next item at the next index
11
11
  path[path.length - 1]++;
12
12
  }
13
13
  }
14
14
  if (incrementalResult.data) {
15
- (0, merge_1.dset)(executionResult, path, incrementalResult.data);
15
+ setObjectKeyPath(executionResult, path, incrementalResult.data);
16
16
  }
17
17
  if (incrementalResult.errors) {
18
18
  executionResult.errors = executionResult.errors || [];
19
19
  executionResult.errors.push(...incrementalResult.errors);
20
20
  }
21
21
  if (incrementalResult.extensions) {
22
- (0, merge_1.dset)(executionResult, 'extensions', incrementalResult.extensions);
22
+ setObjectKeyPath(executionResult, ['extensions'], incrementalResult.extensions);
23
23
  }
24
24
  if (incrementalResult.incremental) {
25
25
  incrementalResult.incremental.forEach(incrementalSubResult => {
@@ -30,3 +30,24 @@ function mergeIncrementalResult({ incrementalResult, executionResult, }) {
30
30
  });
31
31
  }
32
32
  }
33
+ function setObjectKeyPath(obj, keyPath, value) {
34
+ let current = obj;
35
+ let i;
36
+ for (i = 0; i < keyPath.length - 1; i++) {
37
+ const key = keyPath[i];
38
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
39
+ return;
40
+ }
41
+ if (current[key] == null) {
42
+ // Determine if the next key is a number to create an array, otherwise create an object
43
+ current[key] = typeof keyPath[i + 1] === 'number' ? [] : {};
44
+ }
45
+ current = current[key];
46
+ }
47
+ const finalKey = keyPath[i];
48
+ if (finalKey === '__proto__' || finalKey === 'constructor' || finalKey === 'prototype') {
49
+ return;
50
+ }
51
+ const existingValue = current[finalKey];
52
+ current[finalKey] = existingValue != null ? (0, mergeDeep_js_1.mergeDeep)([existingValue, value]) : value;
53
+ }
package/esm/errors.js CHANGED
@@ -35,12 +35,10 @@ export function createGraphQLError(message, options) {
35
35
  ? new Constructor(message, options)
36
36
  : new Constructor(message, options?.nodes, options?.source, options?.positions, options?.path, options?.originalError, options?.extensions);
37
37
  if (options?.coordinate && error.coordinate == null) {
38
- Object.defineProperty(error, 'coordinate', {
39
- value: options.coordinate,
40
- enumerable: true,
41
- configurable: true,
38
+ Object.defineProperties(error, {
39
+ coordinate: { value: options.coordinate, enumerable: true, configurable: true },
40
+ toJSON: { value: toJSON },
42
41
  });
43
- error.toJSON = toJSON;
44
42
  }
45
43
  return error;
46
44
  }
@@ -50,9 +48,12 @@ export function getSchemaCoordinate(error) {
50
48
  export function locatedError(rawError, nodes, path, info) {
51
49
  const error = _locatedError(rawError, nodes, path);
52
50
  // `graphql` locatedError is only changing path and nodes if it is not already defined
53
- if (!error.coordinate && info) {
54
- // @ts-expect-error coordinate is readonly, but we don't want to recreate it just to add coordinate
55
- error.coordinate = `${info.parentType.name}.${info.fieldName}`;
51
+ if (!error.coordinate && info && error.coordinate == null) {
52
+ const coordinate = `${info.parentType.name}.${info.fieldName}`;
53
+ Object.defineProperties(error, {
54
+ coordinate: { value: coordinate, enumerable: true, configurable: true },
55
+ toJSON: { value: toJSON },
56
+ });
56
57
  }
57
58
  return error;
58
59
  }
@@ -1,22 +1,22 @@
1
- import { dset } from 'dset/merge';
1
+ import { mergeDeep } from './mergeDeep.js';
2
2
  export function mergeIncrementalResult({ incrementalResult, executionResult, }) {
3
3
  const path = ['data', ...(incrementalResult.path ?? [])];
4
4
  if (incrementalResult.items) {
5
5
  for (const item of incrementalResult.items) {
6
- dset(executionResult, path, item);
6
+ setObjectKeyPath(executionResult, path, item);
7
7
  // Increment the last path segment (the array index) to merge the next item at the next index
8
8
  path[path.length - 1]++;
9
9
  }
10
10
  }
11
11
  if (incrementalResult.data) {
12
- dset(executionResult, path, incrementalResult.data);
12
+ setObjectKeyPath(executionResult, path, incrementalResult.data);
13
13
  }
14
14
  if (incrementalResult.errors) {
15
15
  executionResult.errors = executionResult.errors || [];
16
16
  executionResult.errors.push(...incrementalResult.errors);
17
17
  }
18
18
  if (incrementalResult.extensions) {
19
- dset(executionResult, 'extensions', incrementalResult.extensions);
19
+ setObjectKeyPath(executionResult, ['extensions'], incrementalResult.extensions);
20
20
  }
21
21
  if (incrementalResult.incremental) {
22
22
  incrementalResult.incremental.forEach(incrementalSubResult => {
@@ -27,3 +27,24 @@ export function mergeIncrementalResult({ incrementalResult, executionResult, })
27
27
  });
28
28
  }
29
29
  }
30
+ function setObjectKeyPath(obj, keyPath, value) {
31
+ let current = obj;
32
+ let i;
33
+ for (i = 0; i < keyPath.length - 1; i++) {
34
+ const key = keyPath[i];
35
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
36
+ return;
37
+ }
38
+ if (current[key] == null) {
39
+ // Determine if the next key is a number to create an array, otherwise create an object
40
+ current[key] = typeof keyPath[i + 1] === 'number' ? [] : {};
41
+ }
42
+ current = current[key];
43
+ }
44
+ const finalKey = keyPath[i];
45
+ if (finalKey === '__proto__' || finalKey === 'constructor' || finalKey === 'prototype') {
46
+ return;
47
+ }
48
+ const existingValue = current[finalKey];
49
+ current[finalKey] = existingValue != null ? mergeDeep([existingValue, value]) : value;
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "10.11.0-alpha-20251114103641-9f5dd54441b8068214cc1ae9afe2803485cf9d9d",
3
+ "version": "10.11.0-alpha-20251114142557-eae3c3166430d65945da6837f875fc7800cc1a26",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -10,7 +10,6 @@
10
10
  "@graphql-typed-document-node/core": "^3.1.1",
11
11
  "@whatwg-node/promise-helpers": "^1.0.0",
12
12
  "cross-inspect": "1.0.1",
13
- "dset": "^3.1.4",
14
13
  "tslib": "^2.4.0"
15
14
  },
16
15
  "repository": {