@graphql-inspector/core 6.3.0 → 6.4.0

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.
@@ -13,6 +13,7 @@ exports.enumValueDeprecationReasonAdded = enumValueDeprecationReasonAdded;
13
13
  exports.enumValueDeprecationReasonRemovedFromMeta = enumValueDeprecationReasonRemovedFromMeta;
14
14
  exports.enumValueDeprecationReasonRemoved = enumValueDeprecationReasonRemoved;
15
15
  const is_deprecated_js_1 = require("../../utils/is-deprecated.js");
16
+ const string_js_1 = require("../../utils/string.js");
16
17
  const change_js_1 = require("./change.js");
17
18
  function buildEnumValueRemovedMessage(args) {
18
19
  return `Enum value '${args.removedEnumValueName}' ${args.isEnumValueDeprecated ? '(deprecated) ' : ''}was removed from enum '${args.enumName}'`;
@@ -66,9 +67,11 @@ function enumValueAdded(newEnum, value) {
66
67
  });
67
68
  }
68
69
  function buildEnumValueDescriptionChangedMessage(args) {
70
+ const oldDesc = (0, string_js_1.fmt)(args.oldEnumValueDescription ?? 'undefined');
71
+ const newDesc = (0, string_js_1.fmt)(args.newEnumValueDescription ?? 'undefined');
69
72
  return args.oldEnumValueDescription === null
70
- ? `Description '${args.newEnumValueDescription ?? 'undefined'}' was added to enum value '${args.enumName}.${args.enumValueName}'`
71
- : `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${args.oldEnumValueDescription ?? 'undefined'}' to '${args.newEnumValueDescription ?? 'undefined'}'`;
73
+ ? `Description '${newDesc}' was added to enum value '${args.enumName}.${args.enumValueName}'`
74
+ : `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${oldDesc}' to '${newDesc}'`;
72
75
  }
73
76
  function enumValueDescriptionChangedFromMeta(args) {
74
77
  return {
@@ -93,7 +96,9 @@ function enumValueDescriptionChanged(newEnum, oldValue, newValue) {
93
96
  });
94
97
  }
95
98
  function buildEnumValueDeprecationChangedMessage(args) {
96
- return `Enum value '${args.enumName}.${args.enumValueName}' deprecation reason changed from '${args.oldEnumValueDeprecationReason}' to '${args.newEnumValueDeprecationReason}'`;
99
+ const oldReason = (0, string_js_1.fmt)(args.oldEnumValueDeprecationReason);
100
+ const newReason = (0, string_js_1.fmt)(args.newEnumValueDeprecationReason);
101
+ return `Enum value '${args.enumName}.${args.enumValueName}' deprecation reason changed from '${oldReason}' to '${newReason}'`;
97
102
  }
98
103
  function enumValueDeprecationReasonChangedFromMeta(args) {
99
104
  return {
@@ -118,7 +123,8 @@ function enumValueDeprecationReasonChanged(newEnum, oldValue, newValue) {
118
123
  });
119
124
  }
120
125
  function buildEnumValueDeprecationReasonAddedMessage(args) {
121
- return `Enum value '${args.enumName}.${args.enumValueName}' was deprecated with reason '${args.addedValueDeprecationReason}'`;
126
+ const reason = (0, string_js_1.fmt)(args.addedValueDeprecationReason);
127
+ return `Enum value '${args.enumName}.${args.enumValueName}' was deprecated with reason '${reason}'`;
122
128
  }
123
129
  function enumValueDeprecationReasonAddedFromMeta(args) {
124
130
  return {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findBestMatch = findBestMatch;
4
4
  exports.safeString = safeString;
5
+ exports.fmt = fmt;
5
6
  const tslib_1 = require("tslib");
6
7
  const object_inspect_1 = tslib_1.__importDefault(require("object-inspect"));
7
8
  function compareTwoStrings(str1, str2) {
@@ -70,3 +71,6 @@ function safeString(obj) {
70
71
  .replace(/\[Object: null prototype\] /g, '')
71
72
  .replace(/(^')|('$)/g, '');
72
73
  }
74
+ function fmt(reason) {
75
+ return reason.replace(/'/g, "\\'");
76
+ }
@@ -1,4 +1,5 @@
1
1
  import { isDeprecated } from '../../utils/is-deprecated.js';
2
+ import { fmt } from '../../utils/string.js';
2
3
  import { ChangeType, CriticalityLevel, } from './change.js';
3
4
  function buildEnumValueRemovedMessage(args) {
4
5
  return `Enum value '${args.removedEnumValueName}' ${args.isEnumValueDeprecated ? '(deprecated) ' : ''}was removed from enum '${args.enumName}'`;
@@ -52,9 +53,11 @@ export function enumValueAdded(newEnum, value) {
52
53
  });
53
54
  }
54
55
  function buildEnumValueDescriptionChangedMessage(args) {
56
+ const oldDesc = fmt(args.oldEnumValueDescription ?? 'undefined');
57
+ const newDesc = fmt(args.newEnumValueDescription ?? 'undefined');
55
58
  return args.oldEnumValueDescription === null
56
- ? `Description '${args.newEnumValueDescription ?? 'undefined'}' was added to enum value '${args.enumName}.${args.enumValueName}'`
57
- : `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${args.oldEnumValueDescription ?? 'undefined'}' to '${args.newEnumValueDescription ?? 'undefined'}'`;
59
+ ? `Description '${newDesc}' was added to enum value '${args.enumName}.${args.enumValueName}'`
60
+ : `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${oldDesc}' to '${newDesc}'`;
58
61
  }
59
62
  export function enumValueDescriptionChangedFromMeta(args) {
60
63
  return {
@@ -79,7 +82,9 @@ export function enumValueDescriptionChanged(newEnum, oldValue, newValue) {
79
82
  });
80
83
  }
81
84
  function buildEnumValueDeprecationChangedMessage(args) {
82
- return `Enum value '${args.enumName}.${args.enumValueName}' deprecation reason changed from '${args.oldEnumValueDeprecationReason}' to '${args.newEnumValueDeprecationReason}'`;
85
+ const oldReason = fmt(args.oldEnumValueDeprecationReason);
86
+ const newReason = fmt(args.newEnumValueDeprecationReason);
87
+ return `Enum value '${args.enumName}.${args.enumValueName}' deprecation reason changed from '${oldReason}' to '${newReason}'`;
83
88
  }
84
89
  export function enumValueDeprecationReasonChangedFromMeta(args) {
85
90
  return {
@@ -104,7 +109,8 @@ export function enumValueDeprecationReasonChanged(newEnum, oldValue, newValue) {
104
109
  });
105
110
  }
106
111
  function buildEnumValueDeprecationReasonAddedMessage(args) {
107
- return `Enum value '${args.enumName}.${args.enumValueName}' was deprecated with reason '${args.addedValueDeprecationReason}'`;
112
+ const reason = fmt(args.addedValueDeprecationReason);
113
+ return `Enum value '${args.enumName}.${args.enumValueName}' was deprecated with reason '${reason}'`;
108
114
  }
109
115
  export function enumValueDeprecationReasonAddedFromMeta(args) {
110
116
  return {
@@ -65,3 +65,6 @@ export function safeString(obj) {
65
65
  .replace(/\[Object: null prototype\] /g, '')
66
66
  .replace(/(^')|('$)/g, '');
67
67
  }
68
+ export function fmt(reason) {
69
+ return reason.replace(/'/g, "\\'");
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-inspector/core",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -12,3 +12,4 @@ export interface BestMatch {
12
12
  }
13
13
  export declare function findBestMatch(mainString: string, targetStrings: Target[]): BestMatch;
14
14
  export declare function safeString(obj: unknown): string;
15
+ export declare function fmt(reason: string): string;
@@ -12,3 +12,4 @@ export interface BestMatch {
12
12
  }
13
13
  export declare function findBestMatch(mainString: string, targetStrings: Target[]): BestMatch;
14
14
  export declare function safeString(obj: unknown): string;
15
+ export declare function fmt(reason: string): string;