@graphql-inspector/action 5.0.16-alpha-20251210011837-ed57c921c80feafc1e499b3e92955f7a79b551ee → 5.0.16

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.
Files changed (37) hide show
  1. package/cjs/core/src/diff/changes/argument.js +7 -1
  2. package/cjs/core/src/diff/changes/directive-usage.js +4 -4
  3. package/cjs/core/src/diff/changes/directive.js +16 -2
  4. package/cjs/core/src/diff/changes/enum.js +7 -5
  5. package/cjs/core/src/diff/changes/field.js +15 -4
  6. package/cjs/core/src/diff/changes/input.js +7 -3
  7. package/cjs/core/src/diff/changes/schema.js +9 -9
  8. package/cjs/core/src/diff/changes/type.js +8 -3
  9. package/cjs/core/src/diff/rules/safe-unreachable.js +1 -1
  10. package/cjs/core/src/diff/rules/suppress-removal-of-deprecated-field.js +4 -4
  11. package/cjs/core/src/diff/schema.js +9 -9
  12. package/cjs/patch/src/patches/schema.js +36 -57
  13. package/esm/core/src/diff/changes/argument.js +8 -2
  14. package/esm/core/src/diff/changes/directive-usage.js +4 -4
  15. package/esm/core/src/diff/changes/directive.js +17 -3
  16. package/esm/core/src/diff/changes/enum.js +7 -5
  17. package/esm/core/src/diff/changes/field.js +15 -4
  18. package/esm/core/src/diff/changes/input.js +8 -4
  19. package/esm/core/src/diff/changes/schema.js +9 -9
  20. package/esm/core/src/diff/changes/type.js +8 -3
  21. package/esm/core/src/diff/rules/safe-unreachable.js +1 -1
  22. package/esm/core/src/diff/rules/suppress-removal-of-deprecated-field.js +4 -4
  23. package/esm/core/src/diff/schema.js +11 -11
  24. package/esm/patch/src/patches/schema.js +36 -57
  25. package/package.json +2 -2
  26. package/typings/core/src/diff/changes/change.d.cts +6 -6
  27. package/typings/core/src/diff/changes/change.d.ts +6 -6
  28. package/typings/core/src/diff/changes/directive-usage.d.cts +1 -1
  29. package/typings/core/src/diff/changes/directive-usage.d.ts +1 -1
  30. package/typings/core/src/diff/changes/schema.d.cts +9 -9
  31. package/typings/core/src/diff/changes/schema.d.ts +9 -9
  32. package/typings/core/src/diff/index.d.cts +1 -1
  33. package/typings/core/src/diff/index.d.ts +1 -1
  34. package/typings/core/src/diff/rules/types.d.cts +2 -2
  35. package/typings/core/src/diff/rules/types.d.ts +2 -2
  36. package/typings/core/src/diff/schema.d.cts +1 -1
  37. package/typings/core/src/diff/schema.d.ts +1 -1
@@ -10,7 +10,13 @@ const graphql_js_1 = require("../../utils/graphql.js");
10
10
  const string_js_1 = require("../../utils/string.js");
11
11
  const change_js_1 = require("./change.js");
12
12
  function buildFieldArgumentDescriptionChangedMessage(args) {
13
- return `Description for argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}' changed from '${args.oldDescription}' to '${args.newDescription}'`;
13
+ if (args.oldDescription === null && args.newDescription !== null) {
14
+ return `Description '${(0, string_js_1.fmt)(args.newDescription)}' was added to argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}'`;
15
+ }
16
+ if (args.newDescription === null && args.oldDescription !== null) {
17
+ return `Description '${(0, string_js_1.fmt)(args.oldDescription)}' was removed from argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}'`;
18
+ }
19
+ return `Description for argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}' changed from '${(0, string_js_1.fmt)(args.oldDescription ?? '')}' to '${(0, string_js_1.fmt)(args.newDescription ?? '')}'`;
14
20
  }
15
21
  function fieldArgumentDescriptionChangedFromMeta(args) {
16
22
  return {
@@ -576,9 +576,9 @@ function directiveUsageAdded(kind, directive, payload, addedToNewType) {
576
576
  type: change_js_1.ChangeType.DirectiveUsageSchemaAdded,
577
577
  meta: {
578
578
  addedDirectiveName: directive.name.value,
579
- schemaTypeName: payload?.getQueryType()?.name || '',
579
+ schemaTypeName: payload.getQueryType()?.name || '',
580
580
  addedToNewType,
581
- directiveRepeatedTimes: directiveRepeatTimes(payload?.astNode?.directives ?? [], directive),
581
+ directiveRepeatedTimes: directiveRepeatTimes(payload.astNode?.directives ?? [], directive),
582
582
  },
583
583
  });
584
584
  }
@@ -731,8 +731,8 @@ function directiveUsageRemoved(kind, directive, payload) {
731
731
  type: change_js_1.ChangeType.DirectiveUsageSchemaRemoved,
732
732
  meta: {
733
733
  removedDirectiveName: directive.name.value,
734
- schemaTypeName: payload?.getQueryType()?.name || '',
735
- directiveRepeatedTimes: directiveRepeatTimes(payload?.astNode?.directives ?? [], directive),
734
+ schemaTypeName: payload.getQueryType()?.name || '',
735
+ directiveRepeatedTimes: directiveRepeatTimes(payload.astNode?.directives ?? [], directive),
736
736
  },
737
737
  });
738
738
  }
@@ -78,7 +78,13 @@ function directiveAdded(directive) {
78
78
  });
79
79
  }
80
80
  function buildDirectiveDescriptionChangedMessage(args) {
81
- return `Directive '${args.directiveName}' description changed from '${args.oldDirectiveDescription ?? 'undefined'}' to '${args.newDirectiveDescription ?? 'undefined'}'`;
81
+ if (args.oldDirectiveDescription === null && args.newDirectiveDescription !== null) {
82
+ return `Directive '${args.directiveName}' description '${(0, string_js_1.fmt)(args.newDirectiveDescription)}' was added`;
83
+ }
84
+ if (args.newDirectiveDescription === null && args.oldDirectiveDescription !== null) {
85
+ return `Directive '${args.directiveName}' description '${(0, string_js_1.fmt)(args.oldDirectiveDescription)}' was removed`;
86
+ }
87
+ return `Directive '${args.directiveName}' description changed from '${(0, string_js_1.fmt)(args.oldDirectiveDescription ?? '')}' to '${(0, string_js_1.fmt)(args.newDirectiveDescription ?? '')}'`;
82
88
  }
83
89
  function directiveDescriptionChangedFromMeta(args) {
84
90
  return {
@@ -258,7 +264,15 @@ function directiveArgumentRemoved(directive, arg) {
258
264
  });
259
265
  }
260
266
  function buildDirectiveArgumentDescriptionChangedMessage(args) {
261
- return `Description for argument '${args.directiveArgumentName}' on directive '${args.directiveName}' changed from '${args.oldDirectiveArgumentDescription}' to '${args.newDirectiveArgumentDescription}'`;
267
+ if (args.oldDirectiveArgumentDescription === null &&
268
+ args.newDirectiveArgumentDescription !== null) {
269
+ return `Description '${(0, string_js_1.fmt)(args.newDirectiveArgumentDescription)}' was added to argument '${args.directiveArgumentName}' on directive '${args.directiveName}'`;
270
+ }
271
+ if (args.newDirectiveArgumentDescription === null &&
272
+ args.oldDirectiveArgumentDescription !== null) {
273
+ return `Description '${(0, string_js_1.fmt)(args.oldDirectiveArgumentDescription)}' was removed from argument '${args.directiveArgumentName}' on directive '${args.directiveName}'`;
274
+ }
275
+ return `Description for argument '${args.directiveArgumentName}' on directive '${args.directiveName}' changed from '${(0, string_js_1.fmt)(args.oldDirectiveArgumentDescription ?? '')}' to '${(0, string_js_1.fmt)(args.newDirectiveArgumentDescription ?? '')}'`;
262
276
  }
263
277
  function directiveArgumentDescriptionChangedFromMeta(args) {
264
278
  return {
@@ -72,11 +72,13 @@ function enumValueAdded(type, value, addedToNewType) {
72
72
  });
73
73
  }
74
74
  function buildEnumValueDescriptionChangedMessage(args) {
75
- const oldDesc = (0, string_js_1.fmt)(args.oldEnumValueDescription ?? 'undefined');
76
- const newDesc = (0, string_js_1.fmt)(args.newEnumValueDescription ?? 'undefined');
77
- return args.oldEnumValueDescription === null
78
- ? `Description '${newDesc}' was added to enum value '${args.enumName}.${args.enumValueName}'`
79
- : `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${oldDesc}' to '${newDesc}'`;
75
+ if (args.oldEnumValueDescription === null && args.newEnumValueDescription !== null) {
76
+ return `Description '${(0, string_js_1.fmt)(args.newEnumValueDescription)}' was added to enum value '${args.enumName}.${args.enumValueName}'`;
77
+ }
78
+ if (args.newEnumValueDescription === null && args.oldEnumValueDescription !== null) {
79
+ return `Description '${(0, string_js_1.fmt)(args.oldEnumValueDescription)}' was removed from enum value '${args.enumName}.${args.enumValueName}'`;
80
+ }
81
+ return `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${(0, string_js_1.fmt)(args.oldEnumValueDescription ?? '')}' to '${(0, string_js_1.fmt)(args.newEnumValueDescription ?? '')}'`;
80
82
  }
81
83
  function enumValueDescriptionChangedFromMeta(args) {
82
84
  return {
@@ -28,6 +28,7 @@ exports.fieldArgumentRemovedFromMeta = fieldArgumentRemovedFromMeta;
28
28
  exports.fieldArgumentRemoved = fieldArgumentRemoved;
29
29
  const graphql_1 = require("graphql");
30
30
  const graphql_js_1 = require("../../utils/graphql.js");
31
+ const string_js_1 = require("../../utils/string.js");
31
32
  const change_js_1 = require("./change.js");
32
33
  function buildFieldRemovedMessage(args) {
33
34
  return `Field '${args.removedFieldName}' ${args.isRemovedFieldDeprecated ? '(deprecated) ' : ''}was removed from ${args.typeType} '${args.typeName}'`;
@@ -85,7 +86,13 @@ function fieldAdded(type, field) {
85
86
  });
86
87
  }
87
88
  function buildFieldDescriptionChangedMessage(args) {
88
- return `Field '${args.typeName}.${args.fieldName}' description changed from '${args.oldDescription}' to '${args.newDescription}'`;
89
+ if (!args.oldDescription && args.newDescription) {
90
+ return `Field '${args.typeName}.${args.fieldName}' description '${(0, string_js_1.fmt)(args.newDescription)}' was added`;
91
+ }
92
+ if (!args.newDescription && args.oldDescription) {
93
+ return `Field '${args.typeName}.${args.fieldName}' description '${(0, string_js_1.fmt)(args.oldDescription)}' was removed`;
94
+ }
95
+ return `Field '${args.typeName}.${args.fieldName}' description changed from '${(0, string_js_1.fmt)(args.oldDescription)}' to '${(0, string_js_1.fmt)(args.newDescription)}'`;
89
96
  }
90
97
  function fieldDescriptionChangedFromMeta(args) {
91
98
  return {
@@ -110,7 +117,8 @@ function fieldDescriptionChanged(type, oldField, newField) {
110
117
  });
111
118
  }
112
119
  function buildFieldDescriptionAddedMessage(args) {
113
- return `Field '${args.typeName}.${args.fieldName}' has description '${args.addedDescription}'`;
120
+ const desc = (0, string_js_1.fmt)(args.addedDescription);
121
+ return `Field '${args.typeName}.${args.fieldName}' has description '${desc}'`;
114
122
  }
115
123
  function fieldDescriptionAddedFromMeta(args) {
116
124
  return {
@@ -201,7 +209,9 @@ function fieldDeprecationRemoved(type, field) {
201
209
  });
202
210
  }
203
211
  function buildFieldDeprecationReasonChangedMessage(args) {
204
- return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${args.oldDeprecationReason}' to '${args.newDeprecationReason}'`;
212
+ const oldReason = (0, string_js_1.fmt)(args.oldDeprecationReason);
213
+ const newReason = (0, string_js_1.fmt)(args.newDeprecationReason);
214
+ return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${oldReason}' to '${newReason}'`;
205
215
  }
206
216
  function fieldDeprecationReasonChangedFromMeta(args) {
207
217
  return {
@@ -226,7 +236,8 @@ function fieldDeprecationReasonChanged(type, oldField, newField) {
226
236
  });
227
237
  }
228
238
  function buildFieldDeprecationReasonAddedMessage(args) {
229
- return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${args.addedDeprecationReason}'`;
239
+ const reason = (0, string_js_1.fmt)(args.addedDeprecationReason);
240
+ return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${reason}'`;
230
241
  }
231
242
  function fieldDeprecationReasonAddedFromMeta(args) {
232
243
  return {
@@ -82,7 +82,8 @@ function inputFieldAdded(input, field, addedToNewType) {
82
82
  });
83
83
  }
84
84
  function buildInputFieldDescriptionAddedMessage(args) {
85
- return `Input field '${args.inputName}.${args.inputFieldName}' has description '${args.addedInputFieldDescription}'`;
85
+ const desc = (0, string_js_1.fmt)(args.addedInputFieldDescription);
86
+ return `Input field '${args.inputName}.${args.inputFieldName}' has description '${desc}'`;
86
87
  }
87
88
  function inputFieldDescriptionAddedFromMeta(args) {
88
89
  return {
@@ -106,7 +107,8 @@ function inputFieldDescriptionAdded(type, field) {
106
107
  });
107
108
  }
108
109
  function buildInputFieldDescriptionRemovedMessage(args) {
109
- return `Description '${args.removedDescription}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
110
+ const desc = (0, string_js_1.fmt)(args.removedDescription);
111
+ return `Description '${desc}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
110
112
  }
111
113
  function inputFieldDescriptionRemovedFromMeta(args) {
112
114
  return {
@@ -130,7 +132,9 @@ function inputFieldDescriptionRemoved(type, field) {
130
132
  });
131
133
  }
132
134
  function buildInputFieldDescriptionChangedMessage(args) {
133
- return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${args.oldInputFieldDescription}' to '${args.newInputFieldDescription}'`;
135
+ const oldDesc = (0, string_js_1.fmt)(args.oldInputFieldDescription);
136
+ const newDesc = (0, string_js_1.fmt)(args.newInputFieldDescription);
137
+ return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${oldDesc}' to '${newDesc}'`;
134
138
  }
135
139
  function inputFieldDescriptionChangedFromMeta(args) {
136
140
  return {
@@ -14,7 +14,7 @@ function schemaQueryTypeChangedFromMeta(args) {
14
14
  return {
15
15
  type: change_js_1.ChangeType.SchemaQueryTypeChanged,
16
16
  criticality: {
17
- level: args.meta.oldQueryTypeName === null
17
+ level: args.meta.oldQueryTypeName === 'unknown'
18
18
  ? change_js_1.CriticalityLevel.NonBreaking
19
19
  : change_js_1.CriticalityLevel.Breaking,
20
20
  },
@@ -23,8 +23,8 @@ function schemaQueryTypeChangedFromMeta(args) {
23
23
  };
24
24
  }
25
25
  function schemaQueryTypeChanged(oldSchema, newSchema) {
26
- const oldName = oldSchema?.getQueryType()?.name || null;
27
- const newName = newSchema?.getQueryType()?.name || null;
26
+ const oldName = (oldSchema.getQueryType() || {}).name || 'unknown';
27
+ const newName = (newSchema.getQueryType() || {}).name || 'unknown';
28
28
  return schemaQueryTypeChangedFromMeta({
29
29
  type: change_js_1.ChangeType.SchemaQueryTypeChanged,
30
30
  meta: {
@@ -40,7 +40,7 @@ function schemaMutationTypeChangedFromMeta(args) {
40
40
  return {
41
41
  type: change_js_1.ChangeType.SchemaMutationTypeChanged,
42
42
  criticality: {
43
- level: args.meta.oldMutationTypeName === null
43
+ level: args.meta.oldMutationTypeName === 'unknown'
44
44
  ? change_js_1.CriticalityLevel.NonBreaking
45
45
  : change_js_1.CriticalityLevel.Breaking,
46
46
  },
@@ -49,8 +49,8 @@ function schemaMutationTypeChangedFromMeta(args) {
49
49
  };
50
50
  }
51
51
  function schemaMutationTypeChanged(oldSchema, newSchema) {
52
- const oldName = oldSchema?.getMutationType()?.name || null;
53
- const newName = newSchema?.getMutationType()?.name || null;
52
+ const oldName = (oldSchema.getMutationType() || {}).name || 'unknown';
53
+ const newName = (newSchema.getMutationType() || {}).name || 'unknown';
54
54
  return schemaMutationTypeChangedFromMeta({
55
55
  type: change_js_1.ChangeType.SchemaMutationTypeChanged,
56
56
  meta: {
@@ -66,7 +66,7 @@ function schemaSubscriptionTypeChangedFromMeta(args) {
66
66
  return {
67
67
  type: change_js_1.ChangeType.SchemaSubscriptionTypeChanged,
68
68
  criticality: {
69
- level: args.meta.oldSubscriptionTypeName === null
69
+ level: args.meta.oldSubscriptionTypeName === 'unknown'
70
70
  ? change_js_1.CriticalityLevel.NonBreaking
71
71
  : change_js_1.CriticalityLevel.Breaking,
72
72
  },
@@ -75,8 +75,8 @@ function schemaSubscriptionTypeChangedFromMeta(args) {
75
75
  };
76
76
  }
77
77
  function schemaSubscriptionTypeChanged(oldSchema, newSchema) {
78
- const oldName = oldSchema?.getSubscriptionType()?.name || null;
79
- const newName = newSchema?.getSubscriptionType()?.name || null;
78
+ const oldName = (oldSchema.getSubscriptionType() || {}).name || 'unknown';
79
+ const newName = (newSchema.getSubscriptionType() || {}).name || 'unknown';
80
80
  return schemaSubscriptionTypeChangedFromMeta({
81
81
  type: change_js_1.ChangeType.SchemaSubscriptionTypeChanged,
82
82
  meta: {
@@ -14,6 +14,7 @@ exports.typeDescriptionAddedFromMeta = typeDescriptionAddedFromMeta;
14
14
  exports.typeDescriptionAdded = typeDescriptionAdded;
15
15
  const graphql_1 = require("graphql");
16
16
  const graphql_js_1 = require("../../utils/graphql.js");
17
+ const string_js_1 = require("../../utils/string.js");
17
18
  const change_js_1 = require("./change.js");
18
19
  function buildTypeRemovedMessage(type) {
19
20
  return `Type '${type.removedTypeName}' was removed`;
@@ -114,7 +115,9 @@ function typeKindChanged(oldType, newType) {
114
115
  });
115
116
  }
116
117
  function buildTypeDescriptionChangedMessage(args) {
117
- return `Description '${args.oldTypeDescription}' on type '${args.typeName}' has changed to '${args.newTypeDescription}'`;
118
+ const oldDesc = (0, string_js_1.fmt)(args.oldTypeDescription);
119
+ const newDesc = (0, string_js_1.fmt)(args.newTypeDescription);
120
+ return `Description '${oldDesc}' on type '${args.typeName}' has changed to '${newDesc}'`;
118
121
  }
119
122
  function typeDescriptionChangedFromMeta(args) {
120
123
  return {
@@ -138,7 +141,8 @@ function typeDescriptionChanged(oldType, newType) {
138
141
  });
139
142
  }
140
143
  function buildTypeDescriptionRemoved(args) {
141
- return `Description '${args.removedTypeDescription}' was removed from object type '${args.typeName}'`;
144
+ const desc = (0, string_js_1.fmt)(args.removedTypeDescription);
145
+ return `Description '${desc}' was removed from object type '${args.typeName}'`;
142
146
  }
143
147
  function typeDescriptionRemovedFromMeta(args) {
144
148
  return {
@@ -161,7 +165,8 @@ function typeDescriptionRemoved(type) {
161
165
  });
162
166
  }
163
167
  function buildTypeDescriptionAddedMessage(args) {
164
- return `Object type '${args.typeName}' has description '${args.addedTypeDescription}'`;
168
+ const desc = (0, string_js_1.fmt)(args.addedTypeDescription);
169
+ return `Object type '${args.typeName}' has description '${desc}'`;
165
170
  }
166
171
  function typeDescriptionAddedFromMeta(args) {
167
172
  return {
@@ -5,7 +5,7 @@ const graphql_js_1 = require("../../utils/graphql.js");
5
5
  const path_js_1 = require("../../utils/path.js");
6
6
  const change_js_1 = require("../changes/change.js");
7
7
  const safeUnreachable = ({ changes, oldSchema }) => {
8
- const reachable = oldSchema ? (0, graphql_js_1.getReachableTypes)(oldSchema) : new Set();
8
+ const reachable = (0, graphql_js_1.getReachableTypes)(oldSchema);
9
9
  return changes.map(change => {
10
10
  if (change.criticality.level === change_js_1.CriticalityLevel.Breaking && change.path) {
11
11
  const [typeName] = (0, path_js_1.parsePath)(change.path);
@@ -11,7 +11,7 @@ const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema }) =>
11
11
  change.criticality.level === change_js_1.CriticalityLevel.Breaking &&
12
12
  change.path) {
13
13
  const [typeName, fieldName] = (0, path_js_1.parsePath)(change.path);
14
- const type = oldSchema?.getType(typeName);
14
+ const type = oldSchema.getType(typeName);
15
15
  if ((0, graphql_1.isObjectType)(type) || (0, graphql_1.isInterfaceType)(type)) {
16
16
  const field = type.getFields()[fieldName];
17
17
  if ((0, is_deprecated_js_1.isDeprecated)(field)) {
@@ -29,7 +29,7 @@ const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema }) =>
29
29
  change.criticality.level === change_js_1.CriticalityLevel.Breaking &&
30
30
  change.path) {
31
31
  const [enumName, enumItem] = (0, path_js_1.parsePath)(change.path);
32
- const type = oldSchema?.getType(enumName);
32
+ const type = oldSchema.getType(enumName);
33
33
  if ((0, graphql_1.isEnumType)(type)) {
34
34
  const item = type.getValue(enumItem);
35
35
  if (item && (0, is_deprecated_js_1.isDeprecated)(item)) {
@@ -47,7 +47,7 @@ const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema }) =>
47
47
  change.criticality.level === change_js_1.CriticalityLevel.Breaking &&
48
48
  change.path) {
49
49
  const [inputName, inputItem] = (0, path_js_1.parsePath)(change.path);
50
- const type = oldSchema?.getType(inputName);
50
+ const type = oldSchema.getType(inputName);
51
51
  if ((0, graphql_1.isInputObjectType)(type)) {
52
52
  const item = type.getFields()[inputItem];
53
53
  if (item && (0, is_deprecated_js_1.isDeprecated)(item)) {
@@ -65,7 +65,7 @@ const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema }) =>
65
65
  change.criticality.level === change_js_1.CriticalityLevel.Breaking &&
66
66
  change.path) {
67
67
  const [typeName] = (0, path_js_1.parsePath)(change.path);
68
- const type = newSchema?.getType(typeName);
68
+ const type = newSchema.getType(typeName);
69
69
  if (!type) {
70
70
  return {
71
71
  ...change,
@@ -21,7 +21,7 @@ function diffSchema(oldSchema, newSchema) {
21
21
  changes.push(change);
22
22
  }
23
23
  changesInSchema(oldSchema, newSchema, addChange);
24
- (0, compare_js_1.compareLists)(Object.values(oldSchema?.getTypeMap() ?? {}).filter(t => !(0, graphql_js_1.isPrimitive)(t) && !(0, graphql_js_1.isForIntrospection)(t)), Object.values(newSchema?.getTypeMap() ?? {}).filter(t => !(0, graphql_js_1.isPrimitive)(t) && !(0, graphql_js_1.isForIntrospection)(t)), {
24
+ (0, compare_js_1.compareLists)(Object.values(oldSchema.getTypeMap()).filter(t => !(0, graphql_js_1.isPrimitive)(t)), Object.values(newSchema.getTypeMap()).filter(t => !(0, graphql_js_1.isPrimitive)(t)), {
25
25
  onAdded(type) {
26
26
  addChange((0, type_js_1.typeAdded)(type));
27
27
  changesInType(null, type, addChange);
@@ -33,7 +33,7 @@ function diffSchema(oldSchema, newSchema) {
33
33
  changesInType(type.oldVersion, type.newVersion, addChange);
34
34
  },
35
35
  });
36
- (0, compare_js_1.compareLists)((oldSchema?.getDirectives() ?? []).filter(t => !(0, graphql_1.isSpecifiedDirective)(t)), (newSchema?.getDirectives() ?? []).filter(t => !(0, graphql_1.isSpecifiedDirective)(t)), {
36
+ (0, compare_js_1.compareLists)(oldSchema.getDirectives(), newSchema.getDirectives(), {
37
37
  onAdded(directive) {
38
38
  addChange((0, directive_js_1.directiveAdded)(directive));
39
39
  (0, directive_js_2.changesInDirective)(null, directive, addChange);
@@ -45,7 +45,7 @@ function diffSchema(oldSchema, newSchema) {
45
45
  (0, directive_js_2.changesInDirective)(directive.oldVersion, directive.newVersion, addChange);
46
46
  },
47
47
  });
48
- (0, compare_js_1.compareDirectiveLists)(oldSchema?.astNode?.directives || [], newSchema?.astNode?.directives || [], {
48
+ (0, compare_js_1.compareDirectiveLists)(oldSchema.astNode?.directives || [], newSchema.astNode?.directives || [], {
49
49
  onAdded(directive) {
50
50
  addChange((0, directive_usage_js_1.directiveUsageAdded)(graphql_1.Kind.SCHEMA_DEFINITION, directive, newSchema, false));
51
51
  (0, directive_usage_js_1.directiveUsageChanged)(null, directive, addChange);
@@ -61,14 +61,14 @@ function diffSchema(oldSchema, newSchema) {
61
61
  }
62
62
  function changesInSchema(oldSchema, newSchema, addChange) {
63
63
  const oldRoot = {
64
- query: (oldSchema?.getQueryType() || {}).name,
65
- mutation: (oldSchema?.getMutationType() || {}).name,
66
- subscription: (oldSchema?.getSubscriptionType() || {}).name,
64
+ query: (oldSchema.getQueryType() || {}).name,
65
+ mutation: (oldSchema.getMutationType() || {}).name,
66
+ subscription: (oldSchema.getSubscriptionType() || {}).name,
67
67
  };
68
68
  const newRoot = {
69
- query: (newSchema?.getQueryType() || {}).name,
70
- mutation: (newSchema?.getMutationType() || {}).name,
71
- subscription: (newSchema?.getSubscriptionType() || {}).name,
69
+ query: (newSchema.getQueryType() || {}).name,
70
+ mutation: (newSchema.getMutationType() || {}).name,
71
+ subscription: (newSchema.getSubscriptionType() || {}).name,
72
72
  };
73
73
  if ((0, compare_js_1.isNotEqual)(oldRoot.query, newRoot.query)) {
74
74
  addChange((0, schema_js_1.schemaQueryTypeChanged)(oldSchema, newSchema));
@@ -11,32 +11,25 @@ function schemaMutationTypeChanged(change, schemaNodes, config, _context) {
11
11
  for (const schemaNode of schemaNodes) {
12
12
  const mutation = schemaNode.operationTypes?.find(({ operation }) => operation === graphql_1.OperationTypeNode.MUTATION);
13
13
  if (!mutation) {
14
- if (change.meta.oldMutationTypeName !== null) {
15
- config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, null), change);
14
+ if (change.meta.oldMutationTypeName !== 'unknown') {
15
+ config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, 'unknown'), change);
16
16
  }
17
- if (change.meta.newMutationTypeName) {
18
- schemaNode.operationTypes = [
19
- ...(schemaNode.operationTypes ?? []),
20
- {
21
- kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
22
- operation: graphql_1.OperationTypeNode.MUTATION,
23
- type: {
24
- kind: graphql_1.Kind.NAMED_TYPE,
25
- name: (0, node_templates_js_1.nameNode)(change.meta.newMutationTypeName),
26
- },
17
+ schemaNode.operationTypes = [
18
+ ...(schemaNode.operationTypes ?? []),
19
+ {
20
+ kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
21
+ operation: graphql_1.OperationTypeNode.MUTATION,
22
+ type: {
23
+ kind: graphql_1.Kind.NAMED_TYPE,
24
+ name: (0, node_templates_js_1.nameNode)(change.meta.newMutationTypeName),
27
25
  },
28
- ];
29
- }
26
+ },
27
+ ];
30
28
  }
31
29
  else {
32
30
  if (mutation.type.name.value !== change.meta.oldMutationTypeName) {
33
31
  config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, mutation?.type.name.value), change);
34
32
  }
35
- if (change.meta.newMutationTypeName === null) {
36
- schemaNode.operationTypes =
37
- schemaNode.operationTypes?.filter(({ operation }) => operation !== graphql_1.OperationTypeNode.MUTATION);
38
- return;
39
- }
40
33
  mutation.type.name = (0, node_templates_js_1.nameNode)(change.meta.newMutationTypeName);
41
34
  }
42
35
  }
@@ -45,32 +38,25 @@ function schemaQueryTypeChanged(change, schemaNodes, config, _context) {
45
38
  for (const schemaNode of schemaNodes) {
46
39
  const query = schemaNode.operationTypes?.find(({ operation }) => operation === graphql_1.OperationTypeNode.MUTATION);
47
40
  if (!query) {
48
- if (change.meta.oldQueryTypeName !== null) {
49
- config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, null), change);
41
+ if (change.meta.oldQueryTypeName !== 'unknown') {
42
+ config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, 'unknown'), change);
50
43
  }
51
- if (change.meta.newQueryTypeName) {
52
- schemaNode.operationTypes = [
53
- ...(schemaNode.operationTypes ?? []),
54
- {
55
- kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
56
- operation: graphql_1.OperationTypeNode.QUERY,
57
- type: {
58
- kind: graphql_1.Kind.NAMED_TYPE,
59
- name: (0, node_templates_js_1.nameNode)(change.meta.newQueryTypeName),
60
- },
44
+ schemaNode.operationTypes = [
45
+ ...(schemaNode.operationTypes ?? []),
46
+ {
47
+ kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
48
+ operation: graphql_1.OperationTypeNode.QUERY,
49
+ type: {
50
+ kind: graphql_1.Kind.NAMED_TYPE,
51
+ name: (0, node_templates_js_1.nameNode)(change.meta.newQueryTypeName),
61
52
  },
62
- ];
63
- }
53
+ },
54
+ ];
64
55
  }
65
56
  else {
66
57
  if (query.type.name.value !== change.meta.oldQueryTypeName) {
67
58
  config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, query?.type.name.value), change);
68
59
  }
69
- if (change.meta.newQueryTypeName === null) {
70
- schemaNode.operationTypes =
71
- schemaNode.operationTypes?.filter(({ operation }) => operation !== graphql_1.OperationTypeNode.QUERY);
72
- return;
73
- }
74
60
  query.type.name = (0, node_templates_js_1.nameNode)(change.meta.newQueryTypeName);
75
61
  }
76
62
  }
@@ -79,32 +65,25 @@ function schemaSubscriptionTypeChanged(change, schemaNodes, config, _context) {
79
65
  for (const schemaNode of schemaNodes) {
80
66
  const sub = schemaNode.operationTypes?.find(({ operation }) => operation === graphql_1.OperationTypeNode.SUBSCRIPTION);
81
67
  if (!sub) {
82
- if (change.meta.oldSubscriptionTypeName !== null) {
83
- config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, null), change);
68
+ if (change.meta.oldSubscriptionTypeName !== 'unknown') {
69
+ config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, 'unknown'), change);
84
70
  }
85
- if (change.meta.newSubscriptionTypeName) {
86
- schemaNode.operationTypes = [
87
- ...(schemaNode.operationTypes ?? []),
88
- {
89
- kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
90
- operation: graphql_1.OperationTypeNode.QUERY,
91
- type: {
92
- kind: graphql_1.Kind.NAMED_TYPE,
93
- name: (0, node_templates_js_1.nameNode)(change.meta.newSubscriptionTypeName),
94
- },
71
+ schemaNode.operationTypes = [
72
+ ...(schemaNode.operationTypes ?? []),
73
+ {
74
+ kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
75
+ operation: graphql_1.OperationTypeNode.QUERY,
76
+ type: {
77
+ kind: graphql_1.Kind.NAMED_TYPE,
78
+ name: (0, node_templates_js_1.nameNode)(change.meta.newSubscriptionTypeName),
95
79
  },
96
- ];
97
- }
80
+ },
81
+ ];
98
82
  }
99
83
  else {
100
84
  if (sub.type.name.value !== change.meta.oldSubscriptionTypeName) {
101
85
  config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, sub?.type.name.value), change);
102
86
  }
103
- if (change.meta.newSubscriptionTypeName === null) {
104
- schemaNode.operationTypes =
105
- schemaNode.operationTypes?.filter(({ operation }) => operation !== graphql_1.OperationTypeNode.SUBSCRIPTION);
106
- return;
107
- }
108
87
  sub.type.name = (0, node_templates_js_1.nameNode)(change.meta.newSubscriptionTypeName);
109
88
  }
110
89
  }
@@ -1,8 +1,14 @@
1
1
  import { safeChangeForInputValue } from '../../utils/graphql.js';
2
- import { safeString } from '../../utils/string.js';
2
+ import { fmt, safeString } from '../../utils/string.js';
3
3
  import { ChangeType, CriticalityLevel, } from './change.js';
4
4
  function buildFieldArgumentDescriptionChangedMessage(args) {
5
- return `Description for argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}' changed from '${args.oldDescription}' to '${args.newDescription}'`;
5
+ if (args.oldDescription === null && args.newDescription !== null) {
6
+ return `Description '${fmt(args.newDescription)}' was added to argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}'`;
7
+ }
8
+ if (args.newDescription === null && args.oldDescription !== null) {
9
+ return `Description '${fmt(args.oldDescription)}' was removed from argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}'`;
10
+ }
11
+ return `Description for argument '${args.argumentName}' on field '${args.typeName}.${args.fieldName}' changed from '${fmt(args.oldDescription ?? '')}' to '${fmt(args.newDescription ?? '')}'`;
6
12
  }
7
13
  export function fieldArgumentDescriptionChangedFromMeta(args) {
8
14
  return {
@@ -545,9 +545,9 @@ export function directiveUsageAdded(kind, directive, payload, addedToNewType) {
545
545
  type: ChangeType.DirectiveUsageSchemaAdded,
546
546
  meta: {
547
547
  addedDirectiveName: directive.name.value,
548
- schemaTypeName: payload?.getQueryType()?.name || '',
548
+ schemaTypeName: payload.getQueryType()?.name || '',
549
549
  addedToNewType,
550
- directiveRepeatedTimes: directiveRepeatTimes(payload?.astNode?.directives ?? [], directive),
550
+ directiveRepeatedTimes: directiveRepeatTimes(payload.astNode?.directives ?? [], directive),
551
551
  },
552
552
  });
553
553
  }
@@ -700,8 +700,8 @@ export function directiveUsageRemoved(kind, directive, payload) {
700
700
  type: ChangeType.DirectiveUsageSchemaRemoved,
701
701
  meta: {
702
702
  removedDirectiveName: directive.name.value,
703
- schemaTypeName: payload?.getQueryType()?.name || '',
704
- directiveRepeatedTimes: directiveRepeatTimes(payload?.astNode?.directives ?? [], directive),
703
+ schemaTypeName: payload.getQueryType()?.name || '',
704
+ directiveRepeatedTimes: directiveRepeatTimes(payload.astNode?.directives ?? [], directive),
705
705
  },
706
706
  });
707
707
  }
@@ -1,6 +1,6 @@
1
1
  import { isNonNullType } from 'graphql';
2
2
  import { safeChangeForInputValue } from '../../utils/graphql.js';
3
- import { safeString } from '../../utils/string.js';
3
+ import { fmt, safeString } from '../../utils/string.js';
4
4
  import { ChangeType, CriticalityLevel, } from './change.js';
5
5
  function buildDirectiveRemovedMessage(args) {
6
6
  return `Directive '${args.removedDirectiveName}' was removed`;
@@ -52,7 +52,13 @@ export function directiveAdded(directive) {
52
52
  });
53
53
  }
54
54
  function buildDirectiveDescriptionChangedMessage(args) {
55
- return `Directive '${args.directiveName}' description changed from '${args.oldDirectiveDescription ?? 'undefined'}' to '${args.newDirectiveDescription ?? 'undefined'}'`;
55
+ if (args.oldDirectiveDescription === null && args.newDirectiveDescription !== null) {
56
+ return `Directive '${args.directiveName}' description '${fmt(args.newDirectiveDescription)}' was added`;
57
+ }
58
+ if (args.newDirectiveDescription === null && args.oldDirectiveDescription !== null) {
59
+ return `Directive '${args.directiveName}' description '${fmt(args.oldDirectiveDescription)}' was removed`;
60
+ }
61
+ return `Directive '${args.directiveName}' description changed from '${fmt(args.oldDirectiveDescription ?? '')}' to '${fmt(args.newDirectiveDescription ?? '')}'`;
56
62
  }
57
63
  export function directiveDescriptionChangedFromMeta(args) {
58
64
  return {
@@ -232,7 +238,15 @@ export function directiveArgumentRemoved(directive, arg) {
232
238
  });
233
239
  }
234
240
  function buildDirectiveArgumentDescriptionChangedMessage(args) {
235
- return `Description for argument '${args.directiveArgumentName}' on directive '${args.directiveName}' changed from '${args.oldDirectiveArgumentDescription}' to '${args.newDirectiveArgumentDescription}'`;
241
+ if (args.oldDirectiveArgumentDescription === null &&
242
+ args.newDirectiveArgumentDescription !== null) {
243
+ return `Description '${fmt(args.newDirectiveArgumentDescription)}' was added to argument '${args.directiveArgumentName}' on directive '${args.directiveName}'`;
244
+ }
245
+ if (args.newDirectiveArgumentDescription === null &&
246
+ args.oldDirectiveArgumentDescription !== null) {
247
+ return `Description '${fmt(args.oldDirectiveArgumentDescription)}' was removed from argument '${args.directiveArgumentName}' on directive '${args.directiveName}'`;
248
+ }
249
+ return `Description for argument '${args.directiveArgumentName}' on directive '${args.directiveName}' changed from '${fmt(args.oldDirectiveArgumentDescription ?? '')}' to '${fmt(args.newDirectiveArgumentDescription ?? '')}'`;
236
250
  }
237
251
  export function directiveArgumentDescriptionChangedFromMeta(args) {
238
252
  return {
@@ -58,11 +58,13 @@ export function enumValueAdded(type, value, addedToNewType) {
58
58
  });
59
59
  }
60
60
  function buildEnumValueDescriptionChangedMessage(args) {
61
- const oldDesc = fmt(args.oldEnumValueDescription ?? 'undefined');
62
- const newDesc = fmt(args.newEnumValueDescription ?? 'undefined');
63
- return args.oldEnumValueDescription === null
64
- ? `Description '${newDesc}' was added to enum value '${args.enumName}.${args.enumValueName}'`
65
- : `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${oldDesc}' to '${newDesc}'`;
61
+ if (args.oldEnumValueDescription === null && args.newEnumValueDescription !== null) {
62
+ return `Description '${fmt(args.newEnumValueDescription)}' was added to enum value '${args.enumName}.${args.enumValueName}'`;
63
+ }
64
+ if (args.newEnumValueDescription === null && args.oldEnumValueDescription !== null) {
65
+ return `Description '${fmt(args.oldEnumValueDescription)}' was removed from enum value '${args.enumName}.${args.enumValueName}'`;
66
+ }
67
+ return `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${fmt(args.oldEnumValueDescription ?? '')}' to '${fmt(args.newEnumValueDescription ?? '')}'`;
66
68
  }
67
69
  export function enumValueDescriptionChangedFromMeta(args) {
68
70
  return {