@graphql-inspector/cli 6.0.4-alpha-20251209221244-ff89fd2707cf16b24ef14c13d056b38377608670 → 6.0.4-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0
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/core/src/diff/changes/argument.js +1 -7
- package/cjs/core/src/diff/changes/directive-usage.js +4 -4
- package/cjs/core/src/diff/changes/directive.js +2 -16
- package/cjs/core/src/diff/changes/enum.js +5 -7
- package/cjs/core/src/diff/changes/field.js +4 -15
- package/cjs/core/src/diff/changes/input.js +3 -7
- package/cjs/core/src/diff/changes/schema.js +30 -12
- package/cjs/core/src/diff/changes/type.js +3 -8
- package/cjs/core/src/diff/rules/safe-unreachable.js +1 -1
- package/cjs/core/src/diff/rules/suppress-removal-of-deprecated-field.js +4 -4
- package/cjs/core/src/diff/schema.js +9 -9
- package/cjs/patch/src/patches/schema.js +57 -36
- package/esm/core/src/diff/changes/argument.js +2 -8
- package/esm/core/src/diff/changes/directive-usage.js +4 -4
- package/esm/core/src/diff/changes/directive.js +3 -17
- package/esm/core/src/diff/changes/enum.js +5 -7
- package/esm/core/src/diff/changes/field.js +4 -15
- package/esm/core/src/diff/changes/input.js +4 -8
- package/esm/core/src/diff/changes/schema.js +30 -12
- package/esm/core/src/diff/changes/type.js +3 -8
- package/esm/core/src/diff/rules/safe-unreachable.js +1 -1
- package/esm/core/src/diff/rules/suppress-removal-of-deprecated-field.js +4 -4
- package/esm/core/src/diff/schema.js +11 -11
- package/esm/patch/src/patches/schema.js +57 -36
- package/package.json +11 -11
- package/typings/core/src/diff/changes/change.d.cts +6 -6
- package/typings/core/src/diff/changes/change.d.ts +6 -6
- package/typings/core/src/diff/changes/directive-usage.d.cts +1 -1
- package/typings/core/src/diff/changes/directive-usage.d.ts +1 -1
- package/typings/core/src/diff/changes/schema.d.cts +9 -9
- package/typings/core/src/diff/changes/schema.d.ts +9 -9
- package/typings/core/src/diff/index.d.cts +1 -1
- package/typings/core/src/diff/index.d.ts +1 -1
- package/typings/core/src/diff/rules/types.d.cts +2 -2
- package/typings/core/src/diff/rules/types.d.ts +2 -2
- package/typings/core/src/diff/schema.d.cts +1 -1
- package/typings/core/src/diff/schema.d.ts +1 -1
|
@@ -58,13 +58,11 @@ export function enumValueAdded(type, value, addedToNewType) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
function buildEnumValueDescriptionChangedMessage(args) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
return `Description for enum value '${args.enumName}.${args.enumValueName}' changed from '${fmt(args.oldEnumValueDescription ?? '')}' to '${fmt(args.newEnumValueDescription ?? '')}'`;
|
|
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}'`;
|
|
68
66
|
}
|
|
69
67
|
export function enumValueDescriptionChangedFromMeta(args) {
|
|
70
68
|
return {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GraphQLDeprecatedDirective, isInterfaceType, isNonNullType, } from 'graphql';
|
|
2
2
|
import { safeChangeForField } from '../../utils/graphql.js';
|
|
3
|
-
import { fmt } from '../../utils/string.js';
|
|
4
3
|
import { ChangeType, CriticalityLevel, } from './change.js';
|
|
5
4
|
function buildFieldRemovedMessage(args) {
|
|
6
5
|
return `Field '${args.removedFieldName}' ${args.isRemovedFieldDeprecated ? '(deprecated) ' : ''}was removed from ${args.typeType} '${args.typeName}'`;
|
|
@@ -58,13 +57,7 @@ export function fieldAdded(type, field) {
|
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
59
|
function buildFieldDescriptionChangedMessage(args) {
|
|
61
|
-
|
|
62
|
-
return `Field '${args.typeName}.${args.fieldName}' description '${fmt(args.newDescription)}' was added`;
|
|
63
|
-
}
|
|
64
|
-
if (!args.newDescription && args.oldDescription) {
|
|
65
|
-
return `Field '${args.typeName}.${args.fieldName}' description '${fmt(args.oldDescription)}' was removed`;
|
|
66
|
-
}
|
|
67
|
-
return `Field '${args.typeName}.${args.fieldName}' description changed from '${fmt(args.oldDescription)}' to '${fmt(args.newDescription)}'`;
|
|
60
|
+
return `Field '${args.typeName}.${args.fieldName}' description changed from '${args.oldDescription}' to '${args.newDescription}'`;
|
|
68
61
|
}
|
|
69
62
|
export function fieldDescriptionChangedFromMeta(args) {
|
|
70
63
|
return {
|
|
@@ -89,8 +82,7 @@ export function fieldDescriptionChanged(type, oldField, newField) {
|
|
|
89
82
|
});
|
|
90
83
|
}
|
|
91
84
|
function buildFieldDescriptionAddedMessage(args) {
|
|
92
|
-
|
|
93
|
-
return `Field '${args.typeName}.${args.fieldName}' has description '${desc}'`;
|
|
85
|
+
return `Field '${args.typeName}.${args.fieldName}' has description '${args.addedDescription}'`;
|
|
94
86
|
}
|
|
95
87
|
export function fieldDescriptionAddedFromMeta(args) {
|
|
96
88
|
return {
|
|
@@ -181,9 +173,7 @@ export function fieldDeprecationRemoved(type, field) {
|
|
|
181
173
|
});
|
|
182
174
|
}
|
|
183
175
|
function buildFieldDeprecationReasonChangedMessage(args) {
|
|
184
|
-
|
|
185
|
-
const newReason = fmt(args.newDeprecationReason);
|
|
186
|
-
return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${oldReason}' to '${newReason}'`;
|
|
176
|
+
return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${args.oldDeprecationReason}' to '${args.newDeprecationReason}'`;
|
|
187
177
|
}
|
|
188
178
|
export function fieldDeprecationReasonChangedFromMeta(args) {
|
|
189
179
|
return {
|
|
@@ -208,8 +198,7 @@ export function fieldDeprecationReasonChanged(type, oldField, newField) {
|
|
|
208
198
|
});
|
|
209
199
|
}
|
|
210
200
|
function buildFieldDeprecationReasonAddedMessage(args) {
|
|
211
|
-
|
|
212
|
-
return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${reason}'`;
|
|
201
|
+
return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${args.addedDeprecationReason}'`;
|
|
213
202
|
}
|
|
214
203
|
export function fieldDeprecationReasonAddedFromMeta(args) {
|
|
215
204
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNonNullType } from 'graphql';
|
|
2
2
|
import { safeChangeForInputValue } from '../../utils/graphql.js';
|
|
3
3
|
import { isDeprecated } from '../../utils/is-deprecated.js';
|
|
4
|
-
import {
|
|
4
|
+
import { safeString } from '../../utils/string.js';
|
|
5
5
|
import { ChangeType, CriticalityLevel, } from './change.js';
|
|
6
6
|
function buildInputFieldRemovedMessage(args) {
|
|
7
7
|
return `Input field '${args.removedFieldName}' ${args.isInputFieldDeprecated ? '(deprecated) ' : ''}was removed from input object type '${args.inputName}'`;
|
|
@@ -65,8 +65,7 @@ export function inputFieldAdded(input, field, addedToNewType) {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
function buildInputFieldDescriptionAddedMessage(args) {
|
|
68
|
-
|
|
69
|
-
return `Input field '${args.inputName}.${args.inputFieldName}' has description '${desc}'`;
|
|
68
|
+
return `Input field '${args.inputName}.${args.inputFieldName}' has description '${args.addedInputFieldDescription}'`;
|
|
70
69
|
}
|
|
71
70
|
export function inputFieldDescriptionAddedFromMeta(args) {
|
|
72
71
|
return {
|
|
@@ -90,8 +89,7 @@ export function inputFieldDescriptionAdded(type, field) {
|
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
function buildInputFieldDescriptionRemovedMessage(args) {
|
|
93
|
-
|
|
94
|
-
return `Description '${desc}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
|
|
92
|
+
return `Description '${args.removedDescription}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
|
|
95
93
|
}
|
|
96
94
|
export function inputFieldDescriptionRemovedFromMeta(args) {
|
|
97
95
|
return {
|
|
@@ -115,9 +113,7 @@ export function inputFieldDescriptionRemoved(type, field) {
|
|
|
115
113
|
});
|
|
116
114
|
}
|
|
117
115
|
function buildInputFieldDescriptionChangedMessage(args) {
|
|
118
|
-
|
|
119
|
-
const newDesc = fmt(args.newInputFieldDescription);
|
|
120
|
-
return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${oldDesc}' to '${newDesc}'`;
|
|
116
|
+
return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${args.oldInputFieldDescription}' to '${args.newInputFieldDescription}'`;
|
|
121
117
|
}
|
|
122
118
|
export function inputFieldDescriptionChangedFromMeta(args) {
|
|
123
119
|
return {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { ChangeType, CriticalityLevel, } from './change.js';
|
|
2
2
|
function buildSchemaQueryTypeChangedMessage(args) {
|
|
3
|
-
|
|
3
|
+
if (args.oldQueryTypeName === null) {
|
|
4
|
+
return `Schema query root type was set to '${args.newQueryTypeName}'.`;
|
|
5
|
+
}
|
|
6
|
+
if (args.newQueryTypeName === null) {
|
|
7
|
+
return `Schema query root type '${args.oldQueryTypeName}' was removed.`;
|
|
8
|
+
}
|
|
9
|
+
return `Schema query root type was changed from '${args.oldQueryTypeName}' to '${args.newQueryTypeName}'`;
|
|
4
10
|
}
|
|
5
11
|
export function schemaQueryTypeChangedFromMeta(args) {
|
|
6
12
|
return {
|
|
7
13
|
type: ChangeType.SchemaQueryTypeChanged,
|
|
8
14
|
criticality: {
|
|
9
|
-
level: args.meta.oldQueryTypeName ===
|
|
15
|
+
level: args.meta.oldQueryTypeName === null
|
|
10
16
|
? CriticalityLevel.NonBreaking
|
|
11
17
|
: CriticalityLevel.Breaking,
|
|
12
18
|
},
|
|
@@ -15,8 +21,8 @@ export function schemaQueryTypeChangedFromMeta(args) {
|
|
|
15
21
|
};
|
|
16
22
|
}
|
|
17
23
|
export function schemaQueryTypeChanged(oldSchema, newSchema) {
|
|
18
|
-
const oldName =
|
|
19
|
-
const newName =
|
|
24
|
+
const oldName = oldSchema?.getQueryType()?.name || null;
|
|
25
|
+
const newName = newSchema?.getQueryType()?.name || null;
|
|
20
26
|
return schemaQueryTypeChangedFromMeta({
|
|
21
27
|
type: ChangeType.SchemaQueryTypeChanged,
|
|
22
28
|
meta: {
|
|
@@ -26,13 +32,19 @@ export function schemaQueryTypeChanged(oldSchema, newSchema) {
|
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
34
|
function buildSchemaMutationTypeChangedMessage(args) {
|
|
29
|
-
|
|
35
|
+
if (args.oldMutationTypeName === null) {
|
|
36
|
+
return `Schema mutation type was set to '${args.newMutationTypeName}'.`;
|
|
37
|
+
}
|
|
38
|
+
if (args.newMutationTypeName === null) {
|
|
39
|
+
return `Schema mutation type '${args.oldMutationTypeName}' was removed.`;
|
|
40
|
+
}
|
|
41
|
+
return `Schema mutation type was changed from '${args.oldMutationTypeName}' to '${args.newMutationTypeName}'`;
|
|
30
42
|
}
|
|
31
43
|
export function schemaMutationTypeChangedFromMeta(args) {
|
|
32
44
|
return {
|
|
33
45
|
type: ChangeType.SchemaMutationTypeChanged,
|
|
34
46
|
criticality: {
|
|
35
|
-
level: args.meta.oldMutationTypeName ===
|
|
47
|
+
level: args.meta.oldMutationTypeName === null
|
|
36
48
|
? CriticalityLevel.NonBreaking
|
|
37
49
|
: CriticalityLevel.Breaking,
|
|
38
50
|
},
|
|
@@ -41,8 +53,8 @@ export function schemaMutationTypeChangedFromMeta(args) {
|
|
|
41
53
|
};
|
|
42
54
|
}
|
|
43
55
|
export function schemaMutationTypeChanged(oldSchema, newSchema) {
|
|
44
|
-
const oldName =
|
|
45
|
-
const newName =
|
|
56
|
+
const oldName = oldSchema?.getMutationType()?.name || null;
|
|
57
|
+
const newName = newSchema?.getMutationType()?.name || null;
|
|
46
58
|
return schemaMutationTypeChangedFromMeta({
|
|
47
59
|
type: ChangeType.SchemaMutationTypeChanged,
|
|
48
60
|
meta: {
|
|
@@ -52,13 +64,19 @@ export function schemaMutationTypeChanged(oldSchema, newSchema) {
|
|
|
52
64
|
});
|
|
53
65
|
}
|
|
54
66
|
function buildSchemaSubscriptionTypeChangedMessage(args) {
|
|
55
|
-
|
|
67
|
+
if (args.oldSubscriptionTypeName === null) {
|
|
68
|
+
return `Schema subscription type was set to '${args.newSubscriptionTypeName}'.`;
|
|
69
|
+
}
|
|
70
|
+
if (args.newSubscriptionTypeName === null) {
|
|
71
|
+
return `Schema subscription type '${args.oldSubscriptionTypeName}' was removed.`;
|
|
72
|
+
}
|
|
73
|
+
return `Schema subscription type was changed from '${args.oldSubscriptionTypeName}' to '${args.newSubscriptionTypeName}'`;
|
|
56
74
|
}
|
|
57
75
|
export function schemaSubscriptionTypeChangedFromMeta(args) {
|
|
58
76
|
return {
|
|
59
77
|
type: ChangeType.SchemaSubscriptionTypeChanged,
|
|
60
78
|
criticality: {
|
|
61
|
-
level: args.meta.oldSubscriptionTypeName ===
|
|
79
|
+
level: args.meta.oldSubscriptionTypeName === null
|
|
62
80
|
? CriticalityLevel.NonBreaking
|
|
63
81
|
: CriticalityLevel.Breaking,
|
|
64
82
|
},
|
|
@@ -67,8 +85,8 @@ export function schemaSubscriptionTypeChangedFromMeta(args) {
|
|
|
67
85
|
};
|
|
68
86
|
}
|
|
69
87
|
export function schemaSubscriptionTypeChanged(oldSchema, newSchema) {
|
|
70
|
-
const oldName =
|
|
71
|
-
const newName =
|
|
88
|
+
const oldName = oldSchema?.getSubscriptionType()?.name || null;
|
|
89
|
+
const newName = newSchema?.getSubscriptionType()?.name || null;
|
|
72
90
|
return schemaSubscriptionTypeChangedFromMeta({
|
|
73
91
|
type: ChangeType.SchemaSubscriptionTypeChanged,
|
|
74
92
|
meta: {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isEnumType, isInputObjectType, isInterfaceType, isObjectType, isUnionType, Kind, } from 'graphql';
|
|
2
2
|
import { getKind } from '../../utils/graphql.js';
|
|
3
|
-
import { fmt } from '../../utils/string.js';
|
|
4
3
|
import { ChangeType, CriticalityLevel, } from './change.js';
|
|
5
4
|
function buildTypeRemovedMessage(type) {
|
|
6
5
|
return `Type '${type.removedTypeName}' was removed`;
|
|
@@ -101,9 +100,7 @@ export function typeKindChanged(oldType, newType) {
|
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
function buildTypeDescriptionChangedMessage(args) {
|
|
104
|
-
|
|
105
|
-
const newDesc = fmt(args.newTypeDescription);
|
|
106
|
-
return `Description '${oldDesc}' on type '${args.typeName}' has changed to '${newDesc}'`;
|
|
103
|
+
return `Description '${args.oldTypeDescription}' on type '${args.typeName}' has changed to '${args.newTypeDescription}'`;
|
|
107
104
|
}
|
|
108
105
|
export function typeDescriptionChangedFromMeta(args) {
|
|
109
106
|
return {
|
|
@@ -127,8 +124,7 @@ export function typeDescriptionChanged(oldType, newType) {
|
|
|
127
124
|
});
|
|
128
125
|
}
|
|
129
126
|
function buildTypeDescriptionRemoved(args) {
|
|
130
|
-
|
|
131
|
-
return `Description '${desc}' was removed from object type '${args.typeName}'`;
|
|
127
|
+
return `Description '${args.removedTypeDescription}' was removed from object type '${args.typeName}'`;
|
|
132
128
|
}
|
|
133
129
|
export function typeDescriptionRemovedFromMeta(args) {
|
|
134
130
|
return {
|
|
@@ -151,8 +147,7 @@ export function typeDescriptionRemoved(type) {
|
|
|
151
147
|
});
|
|
152
148
|
}
|
|
153
149
|
function buildTypeDescriptionAddedMessage(args) {
|
|
154
|
-
|
|
155
|
-
return `Object type '${args.typeName}' has description '${desc}'`;
|
|
150
|
+
return `Object type '${args.typeName}' has description '${args.addedTypeDescription}'`;
|
|
156
151
|
}
|
|
157
152
|
export function typeDescriptionAddedFromMeta(args) {
|
|
158
153
|
return {
|
|
@@ -2,7 +2,7 @@ import { getReachableTypes } from '../../utils/graphql.js';
|
|
|
2
2
|
import { parsePath } from '../../utils/path.js';
|
|
3
3
|
import { CriticalityLevel } from '../changes/change.js';
|
|
4
4
|
export const safeUnreachable = ({ changes, oldSchema }) => {
|
|
5
|
-
const reachable = getReachableTypes(oldSchema);
|
|
5
|
+
const reachable = oldSchema ? getReachableTypes(oldSchema) : new Set();
|
|
6
6
|
return changes.map(change => {
|
|
7
7
|
if (change.criticality.level === CriticalityLevel.Breaking && change.path) {
|
|
8
8
|
const [typeName] = parsePath(change.path);
|
|
@@ -8,7 +8,7 @@ export const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema
|
|
|
8
8
|
change.criticality.level === CriticalityLevel.Breaking &&
|
|
9
9
|
change.path) {
|
|
10
10
|
const [typeName, fieldName] = parsePath(change.path);
|
|
11
|
-
const type = oldSchema
|
|
11
|
+
const type = oldSchema?.getType(typeName);
|
|
12
12
|
if (isObjectType(type) || isInterfaceType(type)) {
|
|
13
13
|
const field = type.getFields()[fieldName];
|
|
14
14
|
if (isDeprecated(field)) {
|
|
@@ -26,7 +26,7 @@ export const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema
|
|
|
26
26
|
change.criticality.level === CriticalityLevel.Breaking &&
|
|
27
27
|
change.path) {
|
|
28
28
|
const [enumName, enumItem] = parsePath(change.path);
|
|
29
|
-
const type = oldSchema
|
|
29
|
+
const type = oldSchema?.getType(enumName);
|
|
30
30
|
if (isEnumType(type)) {
|
|
31
31
|
const item = type.getValue(enumItem);
|
|
32
32
|
if (item && isDeprecated(item)) {
|
|
@@ -44,7 +44,7 @@ export const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema
|
|
|
44
44
|
change.criticality.level === CriticalityLevel.Breaking &&
|
|
45
45
|
change.path) {
|
|
46
46
|
const [inputName, inputItem] = parsePath(change.path);
|
|
47
|
-
const type = oldSchema
|
|
47
|
+
const type = oldSchema?.getType(inputName);
|
|
48
48
|
if (isInputObjectType(type)) {
|
|
49
49
|
const item = type.getFields()[inputItem];
|
|
50
50
|
if (item && isDeprecated(item)) {
|
|
@@ -62,7 +62,7 @@ export const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, newSchema
|
|
|
62
62
|
change.criticality.level === CriticalityLevel.Breaking &&
|
|
63
63
|
change.path) {
|
|
64
64
|
const [typeName] = parsePath(change.path);
|
|
65
|
-
const type = newSchema
|
|
65
|
+
const type = newSchema?.getType(typeName);
|
|
66
66
|
if (!type) {
|
|
67
67
|
return {
|
|
68
68
|
...change,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isEnumType, isInputObjectType, isInterfaceType, isObjectType, isScalarType, isUnionType, Kind, } from 'graphql';
|
|
1
|
+
import { isEnumType, isInputObjectType, isInterfaceType, isObjectType, isScalarType, isSpecifiedDirective, isUnionType, Kind, } from 'graphql';
|
|
2
2
|
import { compareDirectiveLists, compareLists, isNotEqual, isVoid } from '../utils/compare.js';
|
|
3
|
-
import { isPrimitive } from '../utils/graphql.js';
|
|
3
|
+
import { isForIntrospection, isPrimitive } from '../utils/graphql.js';
|
|
4
4
|
import { directiveUsageAdded, directiveUsageChanged, directiveUsageRemoved, } from './changes/directive-usage.js';
|
|
5
5
|
import { directiveAdded, directiveRemoved } from './changes/directive.js';
|
|
6
6
|
import { schemaMutationTypeChanged, schemaQueryTypeChanged, schemaSubscriptionTypeChanged, } from './changes/schema.js';
|
|
@@ -18,7 +18,7 @@ export function diffSchema(oldSchema, newSchema) {
|
|
|
18
18
|
changes.push(change);
|
|
19
19
|
}
|
|
20
20
|
changesInSchema(oldSchema, newSchema, addChange);
|
|
21
|
-
compareLists(Object.values(oldSchema
|
|
21
|
+
compareLists(Object.values(oldSchema?.getTypeMap() ?? {}).filter(t => !isPrimitive(t) && !isForIntrospection(t)), Object.values(newSchema?.getTypeMap() ?? {}).filter(t => !isPrimitive(t) && !isForIntrospection(t)), {
|
|
22
22
|
onAdded(type) {
|
|
23
23
|
addChange(typeAdded(type));
|
|
24
24
|
changesInType(null, type, addChange);
|
|
@@ -30,7 +30,7 @@ export function diffSchema(oldSchema, newSchema) {
|
|
|
30
30
|
changesInType(type.oldVersion, type.newVersion, addChange);
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
|
-
compareLists(oldSchema
|
|
33
|
+
compareLists((oldSchema?.getDirectives() ?? []).filter(t => !isSpecifiedDirective(t)), (newSchema?.getDirectives() ?? []).filter(t => !isSpecifiedDirective(t)), {
|
|
34
34
|
onAdded(directive) {
|
|
35
35
|
addChange(directiveAdded(directive));
|
|
36
36
|
changesInDirective(null, directive, addChange);
|
|
@@ -42,7 +42,7 @@ export function diffSchema(oldSchema, newSchema) {
|
|
|
42
42
|
changesInDirective(directive.oldVersion, directive.newVersion, addChange);
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
|
-
compareDirectiveLists(oldSchema
|
|
45
|
+
compareDirectiveLists(oldSchema?.astNode?.directives || [], newSchema?.astNode?.directives || [], {
|
|
46
46
|
onAdded(directive) {
|
|
47
47
|
addChange(directiveUsageAdded(Kind.SCHEMA_DEFINITION, directive, newSchema, false));
|
|
48
48
|
directiveUsageChanged(null, directive, addChange);
|
|
@@ -58,14 +58,14 @@ export function diffSchema(oldSchema, newSchema) {
|
|
|
58
58
|
}
|
|
59
59
|
function changesInSchema(oldSchema, newSchema, addChange) {
|
|
60
60
|
const oldRoot = {
|
|
61
|
-
query: (oldSchema
|
|
62
|
-
mutation: (oldSchema
|
|
63
|
-
subscription: (oldSchema
|
|
61
|
+
query: (oldSchema?.getQueryType() || {}).name,
|
|
62
|
+
mutation: (oldSchema?.getMutationType() || {}).name,
|
|
63
|
+
subscription: (oldSchema?.getSubscriptionType() || {}).name,
|
|
64
64
|
};
|
|
65
65
|
const newRoot = {
|
|
66
|
-
query: (newSchema
|
|
67
|
-
mutation: (newSchema
|
|
68
|
-
subscription: (newSchema
|
|
66
|
+
query: (newSchema?.getQueryType() || {}).name,
|
|
67
|
+
mutation: (newSchema?.getMutationType() || {}).name,
|
|
68
|
+
subscription: (newSchema?.getSubscriptionType() || {}).name,
|
|
69
69
|
};
|
|
70
70
|
if (isNotEqual(oldRoot.query, newRoot.query)) {
|
|
71
71
|
addChange(schemaQueryTypeChanged(oldSchema, newSchema));
|
|
@@ -6,25 +6,32 @@ export function schemaMutationTypeChanged(change, schemaNodes, config, _context)
|
|
|
6
6
|
for (const schemaNode of schemaNodes) {
|
|
7
7
|
const mutation = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.MUTATION);
|
|
8
8
|
if (!mutation) {
|
|
9
|
-
if (change.meta.oldMutationTypeName !==
|
|
10
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName,
|
|
9
|
+
if (change.meta.oldMutationTypeName !== null) {
|
|
10
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, null), change);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
if (change.meta.newMutationTypeName) {
|
|
13
|
+
schemaNode.operationTypes = [
|
|
14
|
+
...(schemaNode.operationTypes ?? []),
|
|
15
|
+
{
|
|
16
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
17
|
+
operation: OperationTypeNode.MUTATION,
|
|
18
|
+
type: {
|
|
19
|
+
kind: Kind.NAMED_TYPE,
|
|
20
|
+
name: nameNode(change.meta.newMutationTypeName),
|
|
21
|
+
},
|
|
20
22
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
];
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
27
|
if (mutation.type.name.value !== change.meta.oldMutationTypeName) {
|
|
26
28
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, mutation?.type.name.value), change);
|
|
27
29
|
}
|
|
30
|
+
if (change.meta.newMutationTypeName === null) {
|
|
31
|
+
schemaNode.operationTypes =
|
|
32
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.MUTATION);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
28
35
|
mutation.type.name = nameNode(change.meta.newMutationTypeName);
|
|
29
36
|
}
|
|
30
37
|
}
|
|
@@ -33,25 +40,32 @@ export function schemaQueryTypeChanged(change, schemaNodes, config, _context) {
|
|
|
33
40
|
for (const schemaNode of schemaNodes) {
|
|
34
41
|
const query = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.MUTATION);
|
|
35
42
|
if (!query) {
|
|
36
|
-
if (change.meta.oldQueryTypeName !==
|
|
37
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName,
|
|
43
|
+
if (change.meta.oldQueryTypeName !== null) {
|
|
44
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, null), change);
|
|
38
45
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
if (change.meta.newQueryTypeName) {
|
|
47
|
+
schemaNode.operationTypes = [
|
|
48
|
+
...(schemaNode.operationTypes ?? []),
|
|
49
|
+
{
|
|
50
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
51
|
+
operation: OperationTypeNode.QUERY,
|
|
52
|
+
type: {
|
|
53
|
+
kind: Kind.NAMED_TYPE,
|
|
54
|
+
name: nameNode(change.meta.newQueryTypeName),
|
|
55
|
+
},
|
|
47
56
|
},
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
];
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
else {
|
|
52
61
|
if (query.type.name.value !== change.meta.oldQueryTypeName) {
|
|
53
62
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, query?.type.name.value), change);
|
|
54
63
|
}
|
|
64
|
+
if (change.meta.newQueryTypeName === null) {
|
|
65
|
+
schemaNode.operationTypes =
|
|
66
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.QUERY);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
55
69
|
query.type.name = nameNode(change.meta.newQueryTypeName);
|
|
56
70
|
}
|
|
57
71
|
}
|
|
@@ -60,25 +74,32 @@ export function schemaSubscriptionTypeChanged(change, schemaNodes, config, _cont
|
|
|
60
74
|
for (const schemaNode of schemaNodes) {
|
|
61
75
|
const sub = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.SUBSCRIPTION);
|
|
62
76
|
if (!sub) {
|
|
63
|
-
if (change.meta.oldSubscriptionTypeName !==
|
|
64
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName,
|
|
77
|
+
if (change.meta.oldSubscriptionTypeName !== null) {
|
|
78
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, null), change);
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
if (change.meta.newSubscriptionTypeName) {
|
|
81
|
+
schemaNode.operationTypes = [
|
|
82
|
+
...(schemaNode.operationTypes ?? []),
|
|
83
|
+
{
|
|
84
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
85
|
+
operation: OperationTypeNode.QUERY,
|
|
86
|
+
type: {
|
|
87
|
+
kind: Kind.NAMED_TYPE,
|
|
88
|
+
name: nameNode(change.meta.newSubscriptionTypeName),
|
|
89
|
+
},
|
|
74
90
|
},
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
];
|
|
92
|
+
}
|
|
77
93
|
}
|
|
78
94
|
else {
|
|
79
95
|
if (sub.type.name.value !== change.meta.oldSubscriptionTypeName) {
|
|
80
96
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, sub?.type.name.value), change);
|
|
81
97
|
}
|
|
98
|
+
if (change.meta.newSubscriptionTypeName === null) {
|
|
99
|
+
schemaNode.operationTypes =
|
|
100
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.SUBSCRIPTION);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
82
103
|
sub.type.name = nameNode(change.meta.newSubscriptionTypeName);
|
|
83
104
|
}
|
|
84
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/cli",
|
|
3
|
-
"version": "6.0.4-alpha-
|
|
3
|
+
"version": "6.0.4-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
4
4
|
"description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -10,23 +10,23 @@
|
|
|
10
10
|
"@babel/core": "7.26.10",
|
|
11
11
|
"tslib": "2.6.2",
|
|
12
12
|
"yargs": "17.7.2",
|
|
13
|
-
"@graphql-inspector/audit-command": "5.0.16-alpha-
|
|
14
|
-
"@graphql-inspector/code-loader": "5.0.1",
|
|
15
|
-
"@graphql-inspector/commands": "6.0.0",
|
|
13
|
+
"@graphql-inspector/audit-command": "5.0.16-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
16
14
|
"@graphql-inspector/config": "4.0.2",
|
|
17
|
-
"@graphql-inspector/
|
|
18
|
-
"@graphql-inspector/
|
|
15
|
+
"@graphql-inspector/commands": "6.0.0",
|
|
16
|
+
"@graphql-inspector/code-loader": "5.0.1",
|
|
17
|
+
"@graphql-inspector/coverage-command": "6.1.10-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
18
|
+
"@graphql-inspector/diff-command": "6.0.4-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
19
19
|
"@graphql-inspector/docs-command": "5.0.5",
|
|
20
|
-
"@graphql-inspector/git-loader": "5.0.1",
|
|
21
20
|
"@graphql-inspector/github-loader": "5.0.1",
|
|
22
21
|
"@graphql-inspector/graphql-loader": "5.0.1",
|
|
23
|
-
"@graphql-inspector/introspect-command": "5.0.16-alpha-
|
|
22
|
+
"@graphql-inspector/introspect-command": "5.0.16-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
24
23
|
"@graphql-inspector/json-loader": "5.0.1",
|
|
25
24
|
"@graphql-inspector/loaders": "4.1.0",
|
|
25
|
+
"@graphql-inspector/git-loader": "5.0.1",
|
|
26
26
|
"@graphql-inspector/serve-command": "5.0.7",
|
|
27
|
-
"@graphql-inspector/similar-command": "5.0.16-alpha-
|
|
28
|
-
"@graphql-inspector/
|
|
29
|
-
"@graphql-inspector/
|
|
27
|
+
"@graphql-inspector/similar-command": "5.0.16-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
28
|
+
"@graphql-inspector/validate-command": "5.0.16-alpha-20251210214408-83e88e0012f7cbffde895b877242a59aee57ecc0",
|
|
29
|
+
"@graphql-inspector/url-loader": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
@@ -491,22 +491,22 @@ export type ObjectTypeInterfaceRemovedChange = {
|
|
|
491
491
|
export type SchemaQueryTypeChangedChange = {
|
|
492
492
|
type: typeof ChangeType.SchemaQueryTypeChanged;
|
|
493
493
|
meta: {
|
|
494
|
-
oldQueryTypeName: string;
|
|
495
|
-
newQueryTypeName: string;
|
|
494
|
+
oldQueryTypeName: string | null;
|
|
495
|
+
newQueryTypeName: string | null;
|
|
496
496
|
};
|
|
497
497
|
};
|
|
498
498
|
export type SchemaMutationTypeChangedChange = {
|
|
499
499
|
type: typeof ChangeType.SchemaMutationTypeChanged;
|
|
500
500
|
meta: {
|
|
501
|
-
oldMutationTypeName: string;
|
|
502
|
-
newMutationTypeName: string;
|
|
501
|
+
oldMutationTypeName: string | null;
|
|
502
|
+
newMutationTypeName: string | null;
|
|
503
503
|
};
|
|
504
504
|
};
|
|
505
505
|
export type SchemaSubscriptionTypeChangedChange = {
|
|
506
506
|
type: typeof ChangeType.SchemaSubscriptionTypeChanged;
|
|
507
507
|
meta: {
|
|
508
|
-
oldSubscriptionTypeName: string;
|
|
509
|
-
newSubscriptionTypeName: string;
|
|
508
|
+
oldSubscriptionTypeName: string | null;
|
|
509
|
+
newSubscriptionTypeName: string | null;
|
|
510
510
|
};
|
|
511
511
|
};
|
|
512
512
|
export type TypeRemovedChange = {
|
|
@@ -491,22 +491,22 @@ export type ObjectTypeInterfaceRemovedChange = {
|
|
|
491
491
|
export type SchemaQueryTypeChangedChange = {
|
|
492
492
|
type: typeof ChangeType.SchemaQueryTypeChanged;
|
|
493
493
|
meta: {
|
|
494
|
-
oldQueryTypeName: string;
|
|
495
|
-
newQueryTypeName: string;
|
|
494
|
+
oldQueryTypeName: string | null;
|
|
495
|
+
newQueryTypeName: string | null;
|
|
496
496
|
};
|
|
497
497
|
};
|
|
498
498
|
export type SchemaMutationTypeChangedChange = {
|
|
499
499
|
type: typeof ChangeType.SchemaMutationTypeChanged;
|
|
500
500
|
meta: {
|
|
501
|
-
oldMutationTypeName: string;
|
|
502
|
-
newMutationTypeName: string;
|
|
501
|
+
oldMutationTypeName: string | null;
|
|
502
|
+
newMutationTypeName: string | null;
|
|
503
503
|
};
|
|
504
504
|
};
|
|
505
505
|
export type SchemaSubscriptionTypeChangedChange = {
|
|
506
506
|
type: typeof ChangeType.SchemaSubscriptionTypeChanged;
|
|
507
507
|
meta: {
|
|
508
|
-
oldSubscriptionTypeName: string;
|
|
509
|
-
newSubscriptionTypeName: string;
|
|
508
|
+
oldSubscriptionTypeName: string | null;
|
|
509
|
+
newSubscriptionTypeName: string | null;
|
|
510
510
|
};
|
|
511
511
|
};
|
|
512
512
|
export type TypeRemovedChange = {
|
|
@@ -32,7 +32,7 @@ type KindToPayload = {
|
|
|
32
32
|
change: DirectiveUsageEnumValueAddedChange | DirectiveUsageEnumValueRemovedChange;
|
|
33
33
|
};
|
|
34
34
|
[Kind.SCHEMA_DEFINITION]: {
|
|
35
|
-
input: GraphQLSchema;
|
|
35
|
+
input: GraphQLSchema | null;
|
|
36
36
|
change: DirectiveUsageSchemaAddedChange | DirectiveUsageSchemaRemovedChange;
|
|
37
37
|
};
|
|
38
38
|
[Kind.SCALAR_TYPE_DEFINITION]: {
|
|
@@ -32,7 +32,7 @@ type KindToPayload = {
|
|
|
32
32
|
change: DirectiveUsageEnumValueAddedChange | DirectiveUsageEnumValueRemovedChange;
|
|
33
33
|
};
|
|
34
34
|
[Kind.SCHEMA_DEFINITION]: {
|
|
35
|
-
input: GraphQLSchema;
|
|
35
|
+
input: GraphQLSchema | null;
|
|
36
36
|
change: DirectiveUsageSchemaAddedChange | DirectiveUsageSchemaRemovedChange;
|
|
37
37
|
};
|
|
38
38
|
[Kind.SCALAR_TYPE_DEFINITION]: {
|