@graphql-tools/utils 10.11.0-alpha-20251113153404-aa3328c5a0bf7ec4395c788dde43fda08409300c → 10.11.0-alpha-20251113162628-fc5dd9a67f15da93da0f992ac3e357a9431c42bc

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
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toJSON = void 0;
3
4
  exports.isGraphQLErrorLike = isGraphQLErrorLike;
4
5
  exports.createGraphQLError = createGraphQLError;
5
6
  exports.getSchemaCoordinate = getSchemaCoordinate;
@@ -24,6 +25,13 @@ function isGraphQLErrorLike(error) {
24
25
  typeof error === 'object' &&
25
26
  Object.keys(error).every(key => possibleGraphQLErrorProperties.includes(key)));
26
27
  }
28
+ const toJSON = function toJSON() {
29
+ const formattedError = graphql_1.GraphQLError.prototype.toJSON.apply(this);
30
+ // @ts-expect-error coordinate is readonly
31
+ formattedError.coordinate = this.coordinate;
32
+ return formattedError;
33
+ };
34
+ exports.toJSON = toJSON;
27
35
  function createGraphQLError(message, options) {
28
36
  if (options?.originalError &&
29
37
  !(options.originalError instanceof Error) &&
@@ -41,6 +49,7 @@ function createGraphQLError(message, options) {
41
49
  enumerable: true,
42
50
  configurable: true,
43
51
  });
52
+ error.toJSON = exports.toJSON;
44
53
  }
45
54
  return error;
46
55
  }
package/esm/errors.js CHANGED
@@ -17,6 +17,12 @@ export function isGraphQLErrorLike(error) {
17
17
  typeof error === 'object' &&
18
18
  Object.keys(error).every(key => possibleGraphQLErrorProperties.includes(key)));
19
19
  }
20
+ export const toJSON = function toJSON() {
21
+ const formattedError = GraphQLError.prototype.toJSON.apply(this);
22
+ // @ts-expect-error coordinate is readonly
23
+ formattedError.coordinate = this.coordinate;
24
+ return formattedError;
25
+ };
20
26
  export function createGraphQLError(message, options) {
21
27
  if (options?.originalError &&
22
28
  !(options.originalError instanceof Error) &&
@@ -34,6 +40,7 @@ export function createGraphQLError(message, options) {
34
40
  enumerable: true,
35
41
  configurable: true,
36
42
  });
43
+ error.toJSON = toJSON;
37
44
  }
38
45
  return error;
39
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "10.11.0-alpha-20251113153404-aa3328c5a0bf7ec4395c788dde43fda08409300c",
3
+ "version": "10.11.0-alpha-20251113162628-fc5dd9a67f15da93da0f992ac3e357a9431c42bc",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -18,8 +18,15 @@ declare module 'graphql' {
18
18
  */
19
19
  readonly coordinate?: string;
20
20
  }
21
+ interface GraphQLFormattedError {
22
+ /**
23
+ * An optional schema coordinate (e.g. "MyType.myField") associated with this error.
24
+ */
25
+ readonly coordinate?: string;
26
+ }
21
27
  }
22
28
  export declare function isGraphQLErrorLike(error: any): boolean;
29
+ export declare const toJSON: GraphQLError['toJSON'];
23
30
  export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
24
31
  type SchemaCoordinateInfo = {
25
32
  fieldName: string;
@@ -18,8 +18,15 @@ declare module 'graphql' {
18
18
  */
19
19
  readonly coordinate?: string;
20
20
  }
21
+ interface GraphQLFormattedError {
22
+ /**
23
+ * An optional schema coordinate (e.g. "MyType.myField") associated with this error.
24
+ */
25
+ readonly coordinate?: string;
26
+ }
21
27
  }
22
28
  export declare function isGraphQLErrorLike(error: any): boolean;
29
+ export declare const toJSON: GraphQLError['toJSON'];
23
30
  export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
24
31
  type SchemaCoordinateInfo = {
25
32
  fieldName: string;