@graphql-inspector/action 5.0.16-alpha-20251209221244-ff89fd2707cf16b24ef14c13d056b38377608670 → 5.0.16-alpha-20251210011837-ed57c921c80feafc1e499b3e92955f7a79b551ee
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 +9 -9
- 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 +9 -9
- 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 +2 -2
- 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
|
@@ -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 {
|
|
@@ -6,7 +6,7 @@ export function schemaQueryTypeChangedFromMeta(args) {
|
|
|
6
6
|
return {
|
|
7
7
|
type: ChangeType.SchemaQueryTypeChanged,
|
|
8
8
|
criticality: {
|
|
9
|
-
level: args.meta.oldQueryTypeName ===
|
|
9
|
+
level: args.meta.oldQueryTypeName === null
|
|
10
10
|
? CriticalityLevel.NonBreaking
|
|
11
11
|
: CriticalityLevel.Breaking,
|
|
12
12
|
},
|
|
@@ -15,8 +15,8 @@ export function schemaQueryTypeChangedFromMeta(args) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
export function schemaQueryTypeChanged(oldSchema, newSchema) {
|
|
18
|
-
const oldName =
|
|
19
|
-
const newName =
|
|
18
|
+
const oldName = oldSchema?.getQueryType()?.name || null;
|
|
19
|
+
const newName = newSchema?.getQueryType()?.name || null;
|
|
20
20
|
return schemaQueryTypeChangedFromMeta({
|
|
21
21
|
type: ChangeType.SchemaQueryTypeChanged,
|
|
22
22
|
meta: {
|
|
@@ -32,7 +32,7 @@ export function schemaMutationTypeChangedFromMeta(args) {
|
|
|
32
32
|
return {
|
|
33
33
|
type: ChangeType.SchemaMutationTypeChanged,
|
|
34
34
|
criticality: {
|
|
35
|
-
level: args.meta.oldMutationTypeName ===
|
|
35
|
+
level: args.meta.oldMutationTypeName === null
|
|
36
36
|
? CriticalityLevel.NonBreaking
|
|
37
37
|
: CriticalityLevel.Breaking,
|
|
38
38
|
},
|
|
@@ -41,8 +41,8 @@ export function schemaMutationTypeChangedFromMeta(args) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export function schemaMutationTypeChanged(oldSchema, newSchema) {
|
|
44
|
-
const oldName =
|
|
45
|
-
const newName =
|
|
44
|
+
const oldName = oldSchema?.getMutationType()?.name || null;
|
|
45
|
+
const newName = newSchema?.getMutationType()?.name || null;
|
|
46
46
|
return schemaMutationTypeChangedFromMeta({
|
|
47
47
|
type: ChangeType.SchemaMutationTypeChanged,
|
|
48
48
|
meta: {
|
|
@@ -58,7 +58,7 @@ export function schemaSubscriptionTypeChangedFromMeta(args) {
|
|
|
58
58
|
return {
|
|
59
59
|
type: ChangeType.SchemaSubscriptionTypeChanged,
|
|
60
60
|
criticality: {
|
|
61
|
-
level: args.meta.oldSubscriptionTypeName ===
|
|
61
|
+
level: args.meta.oldSubscriptionTypeName === null
|
|
62
62
|
? CriticalityLevel.NonBreaking
|
|
63
63
|
: CriticalityLevel.Breaking,
|
|
64
64
|
},
|
|
@@ -67,8 +67,8 @@ export function schemaSubscriptionTypeChangedFromMeta(args) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
export function schemaSubscriptionTypeChanged(oldSchema, newSchema) {
|
|
70
|
-
const oldName =
|
|
71
|
-
const newName =
|
|
70
|
+
const oldName = oldSchema?.getSubscriptionType()?.name || null;
|
|
71
|
+
const newName = newSchema?.getSubscriptionType()?.name || null;
|
|
72
72
|
return schemaSubscriptionTypeChangedFromMeta({
|
|
73
73
|
type: ChangeType.SchemaSubscriptionTypeChanged,
|
|
74
74
|
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/action",
|
|
3
|
-
"version": "5.0.16-alpha-
|
|
3
|
+
"version": "5.0.16-alpha-20251210011837-ed57c921c80feafc1e499b3e92955f7a79b551ee",
|
|
4
4
|
"description": "GraphQL Inspector functionality for GitHub Actions",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"dependencies": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"probot": "13.2.2",
|
|
12
12
|
"tslib": "2.6.2",
|
|
13
13
|
"@graphql-inspector/commands": "6.0.0",
|
|
14
|
-
"@graphql-inspector/core": "7.0
|
|
14
|
+
"@graphql-inspector/core": "7.1.0-alpha-20251210011837-ed57c921c80feafc1e499b3e92955f7a79b551ee"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"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]: {
|
|
@@ -7,11 +7,11 @@ export declare function schemaQueryTypeChangedFromMeta(args: SchemaQueryTypeChan
|
|
|
7
7
|
};
|
|
8
8
|
readonly message: string;
|
|
9
9
|
readonly meta: {
|
|
10
|
-
oldQueryTypeName: string;
|
|
11
|
-
newQueryTypeName: string;
|
|
10
|
+
oldQueryTypeName: string | null;
|
|
11
|
+
newQueryTypeName: string | null;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change<typeof ChangeType.SchemaQueryTypeChanged>;
|
|
14
|
+
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null): Change<typeof ChangeType.SchemaQueryTypeChanged>;
|
|
15
15
|
export declare function schemaMutationTypeChangedFromMeta(args: SchemaMutationTypeChangedChange): {
|
|
16
16
|
readonly type: "SCHEMA_MUTATION_TYPE_CHANGED";
|
|
17
17
|
readonly criticality: {
|
|
@@ -19,11 +19,11 @@ export declare function schemaMutationTypeChangedFromMeta(args: SchemaMutationTy
|
|
|
19
19
|
};
|
|
20
20
|
readonly message: string;
|
|
21
21
|
readonly meta: {
|
|
22
|
-
oldMutationTypeName: string;
|
|
23
|
-
newMutationTypeName: string;
|
|
22
|
+
oldMutationTypeName: string | null;
|
|
23
|
+
newMutationTypeName: string | null;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change<typeof ChangeType.SchemaMutationTypeChanged>;
|
|
26
|
+
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null): Change<typeof ChangeType.SchemaMutationTypeChanged>;
|
|
27
27
|
export declare function schemaSubscriptionTypeChangedFromMeta(args: SchemaSubscriptionTypeChangedChange): {
|
|
28
28
|
readonly type: "SCHEMA_SUBSCRIPTION_TYPE_CHANGED";
|
|
29
29
|
readonly criticality: {
|
|
@@ -31,8 +31,8 @@ export declare function schemaSubscriptionTypeChangedFromMeta(args: SchemaSubscr
|
|
|
31
31
|
};
|
|
32
32
|
readonly message: string;
|
|
33
33
|
readonly meta: {
|
|
34
|
-
oldSubscriptionTypeName: string;
|
|
35
|
-
newSubscriptionTypeName: string;
|
|
34
|
+
oldSubscriptionTypeName: string | null;
|
|
35
|
+
newSubscriptionTypeName: string | null;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change<typeof ChangeType.SchemaSubscriptionTypeChanged>;
|
|
38
|
+
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null): Change<typeof ChangeType.SchemaSubscriptionTypeChanged>;
|
|
@@ -7,11 +7,11 @@ export declare function schemaQueryTypeChangedFromMeta(args: SchemaQueryTypeChan
|
|
|
7
7
|
};
|
|
8
8
|
readonly message: string;
|
|
9
9
|
readonly meta: {
|
|
10
|
-
oldQueryTypeName: string;
|
|
11
|
-
newQueryTypeName: string;
|
|
10
|
+
oldQueryTypeName: string | null;
|
|
11
|
+
newQueryTypeName: string | null;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change<typeof ChangeType.SchemaQueryTypeChanged>;
|
|
14
|
+
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null): Change<typeof ChangeType.SchemaQueryTypeChanged>;
|
|
15
15
|
export declare function schemaMutationTypeChangedFromMeta(args: SchemaMutationTypeChangedChange): {
|
|
16
16
|
readonly type: "SCHEMA_MUTATION_TYPE_CHANGED";
|
|
17
17
|
readonly criticality: {
|
|
@@ -19,11 +19,11 @@ export declare function schemaMutationTypeChangedFromMeta(args: SchemaMutationTy
|
|
|
19
19
|
};
|
|
20
20
|
readonly message: string;
|
|
21
21
|
readonly meta: {
|
|
22
|
-
oldMutationTypeName: string;
|
|
23
|
-
newMutationTypeName: string;
|
|
22
|
+
oldMutationTypeName: string | null;
|
|
23
|
+
newMutationTypeName: string | null;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change<typeof ChangeType.SchemaMutationTypeChanged>;
|
|
26
|
+
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null): Change<typeof ChangeType.SchemaMutationTypeChanged>;
|
|
27
27
|
export declare function schemaSubscriptionTypeChangedFromMeta(args: SchemaSubscriptionTypeChangedChange): {
|
|
28
28
|
readonly type: "SCHEMA_SUBSCRIPTION_TYPE_CHANGED";
|
|
29
29
|
readonly criticality: {
|
|
@@ -31,8 +31,8 @@ export declare function schemaSubscriptionTypeChangedFromMeta(args: SchemaSubscr
|
|
|
31
31
|
};
|
|
32
32
|
readonly message: string;
|
|
33
33
|
readonly meta: {
|
|
34
|
-
oldSubscriptionTypeName: string;
|
|
35
|
-
newSubscriptionTypeName: string;
|
|
34
|
+
oldSubscriptionTypeName: string | null;
|
|
35
|
+
newSubscriptionTypeName: string | null;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change<typeof ChangeType.SchemaSubscriptionTypeChanged>;
|
|
38
|
+
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null): Change<typeof ChangeType.SchemaSubscriptionTypeChanged>;
|
|
@@ -6,4 +6,4 @@ export * from './rules/types.cjs';
|
|
|
6
6
|
export declare const DiffRule: typeof rules;
|
|
7
7
|
export * from './onComplete/types.cjs';
|
|
8
8
|
export type { UsageHandler } from './rules/consider-usage.cjs';
|
|
9
|
-
export declare function diff(oldSchema: GraphQLSchema, newSchema: GraphQLSchema, rules?: Rule[], config?: rules.ConsiderUsageConfig): Promise<Change[]>;
|
|
9
|
+
export declare function diff(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null, rules?: Rule[], config?: rules.ConsiderUsageConfig): Promise<Change[]>;
|
|
@@ -6,4 +6,4 @@ export * from './rules/types.js';
|
|
|
6
6
|
export declare const DiffRule: typeof rules;
|
|
7
7
|
export * from './onComplete/types.js';
|
|
8
8
|
export type { UsageHandler } from './rules/consider-usage.js';
|
|
9
|
-
export declare function diff(oldSchema: GraphQLSchema, newSchema: GraphQLSchema, rules?: Rule[], config?: rules.ConsiderUsageConfig): Promise<Change[]>;
|
|
9
|
+
export declare function diff(oldSchema: GraphQLSchema | null, newSchema: GraphQLSchema | null, rules?: Rule[], config?: rules.ConsiderUsageConfig): Promise<Change[]>;
|
|
@@ -2,7 +2,7 @@ import { GraphQLSchema } from 'graphql';
|
|
|
2
2
|
import { Change } from '../changes/change.cjs';
|
|
3
3
|
export type Rule<TConfig = any> = (input: {
|
|
4
4
|
changes: Change[];
|
|
5
|
-
oldSchema: GraphQLSchema;
|
|
6
|
-
newSchema: GraphQLSchema;
|
|
5
|
+
oldSchema: GraphQLSchema | null;
|
|
6
|
+
newSchema: GraphQLSchema | null;
|
|
7
7
|
config: TConfig;
|
|
8
8
|
}) => Change[] | Promise<Change[]>;
|