@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.
- package/cjs/core/src/diff/changes/argument.js +7 -1
- package/cjs/core/src/diff/changes/directive-usage.js +4 -4
- package/cjs/core/src/diff/changes/directive.js +16 -2
- package/cjs/core/src/diff/changes/enum.js +7 -5
- package/cjs/core/src/diff/changes/field.js +15 -4
- package/cjs/core/src/diff/changes/input.js +7 -3
- package/cjs/core/src/diff/changes/schema.js +9 -9
- package/cjs/core/src/diff/changes/type.js +8 -3
- 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 +36 -57
- package/esm/core/src/diff/changes/argument.js +8 -2
- package/esm/core/src/diff/changes/directive-usage.js +4 -4
- package/esm/core/src/diff/changes/directive.js +17 -3
- package/esm/core/src/diff/changes/enum.js +7 -5
- package/esm/core/src/diff/changes/field.js +15 -4
- package/esm/core/src/diff/changes/input.js +8 -4
- package/esm/core/src/diff/changes/schema.js +9 -9
- package/esm/core/src/diff/changes/type.js +8 -3
- 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 +36 -57
- 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,5 +1,6 @@
|
|
|
1
1
|
import { GraphQLDeprecatedDirective, isInterfaceType, isNonNullType, } from 'graphql';
|
|
2
2
|
import { safeChangeForField } from '../../utils/graphql.js';
|
|
3
|
+
import { fmt } from '../../utils/string.js';
|
|
3
4
|
import { ChangeType, CriticalityLevel, } from './change.js';
|
|
4
5
|
function buildFieldRemovedMessage(args) {
|
|
5
6
|
return `Field '${args.removedFieldName}' ${args.isRemovedFieldDeprecated ? '(deprecated) ' : ''}was removed from ${args.typeType} '${args.typeName}'`;
|
|
@@ -57,7 +58,13 @@ export function fieldAdded(type, field) {
|
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
function buildFieldDescriptionChangedMessage(args) {
|
|
60
|
-
|
|
61
|
+
if (!args.oldDescription && args.newDescription) {
|
|
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)}'`;
|
|
61
68
|
}
|
|
62
69
|
export function fieldDescriptionChangedFromMeta(args) {
|
|
63
70
|
return {
|
|
@@ -82,7 +89,8 @@ export function fieldDescriptionChanged(type, oldField, newField) {
|
|
|
82
89
|
});
|
|
83
90
|
}
|
|
84
91
|
function buildFieldDescriptionAddedMessage(args) {
|
|
85
|
-
|
|
92
|
+
const desc = fmt(args.addedDescription);
|
|
93
|
+
return `Field '${args.typeName}.${args.fieldName}' has description '${desc}'`;
|
|
86
94
|
}
|
|
87
95
|
export function fieldDescriptionAddedFromMeta(args) {
|
|
88
96
|
return {
|
|
@@ -173,7 +181,9 @@ export function fieldDeprecationRemoved(type, field) {
|
|
|
173
181
|
});
|
|
174
182
|
}
|
|
175
183
|
function buildFieldDeprecationReasonChangedMessage(args) {
|
|
176
|
-
|
|
184
|
+
const oldReason = fmt(args.oldDeprecationReason);
|
|
185
|
+
const newReason = fmt(args.newDeprecationReason);
|
|
186
|
+
return `Deprecation reason on field '${args.typeName}.${args.fieldName}' has changed from '${oldReason}' to '${newReason}'`;
|
|
177
187
|
}
|
|
178
188
|
export function fieldDeprecationReasonChangedFromMeta(args) {
|
|
179
189
|
return {
|
|
@@ -198,7 +208,8 @@ export function fieldDeprecationReasonChanged(type, oldField, newField) {
|
|
|
198
208
|
});
|
|
199
209
|
}
|
|
200
210
|
function buildFieldDeprecationReasonAddedMessage(args) {
|
|
201
|
-
|
|
211
|
+
const reason = fmt(args.addedDeprecationReason);
|
|
212
|
+
return `Field '${args.typeName}.${args.fieldName}' has deprecation reason '${reason}'`;
|
|
202
213
|
}
|
|
203
214
|
export function fieldDeprecationReasonAddedFromMeta(args) {
|
|
204
215
|
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 { safeString } from '../../utils/string.js';
|
|
4
|
+
import { fmt, 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,7 +65,8 @@ export function inputFieldAdded(input, field, addedToNewType) {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
function buildInputFieldDescriptionAddedMessage(args) {
|
|
68
|
-
|
|
68
|
+
const desc = fmt(args.addedInputFieldDescription);
|
|
69
|
+
return `Input field '${args.inputName}.${args.inputFieldName}' has description '${desc}'`;
|
|
69
70
|
}
|
|
70
71
|
export function inputFieldDescriptionAddedFromMeta(args) {
|
|
71
72
|
return {
|
|
@@ -89,7 +90,8 @@ export function inputFieldDescriptionAdded(type, field) {
|
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
function buildInputFieldDescriptionRemovedMessage(args) {
|
|
92
|
-
|
|
93
|
+
const desc = fmt(args.removedDescription);
|
|
94
|
+
return `Description '${desc}' was removed from input field '${args.inputName}.${args.inputFieldName}'`;
|
|
93
95
|
}
|
|
94
96
|
export function inputFieldDescriptionRemovedFromMeta(args) {
|
|
95
97
|
return {
|
|
@@ -113,7 +115,9 @@ export function inputFieldDescriptionRemoved(type, field) {
|
|
|
113
115
|
});
|
|
114
116
|
}
|
|
115
117
|
function buildInputFieldDescriptionChangedMessage(args) {
|
|
116
|
-
|
|
118
|
+
const oldDesc = fmt(args.oldInputFieldDescription);
|
|
119
|
+
const newDesc = fmt(args.newInputFieldDescription);
|
|
120
|
+
return `Input field '${args.inputName}.${args.inputFieldName}' description changed from '${oldDesc}' to '${newDesc}'`;
|
|
117
121
|
}
|
|
118
122
|
export function inputFieldDescriptionChangedFromMeta(args) {
|
|
119
123
|
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 === 'unknown'
|
|
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 = oldSchema
|
|
19
|
-
const newName = newSchema
|
|
18
|
+
const oldName = (oldSchema.getQueryType() || {}).name || 'unknown';
|
|
19
|
+
const newName = (newSchema.getQueryType() || {}).name || 'unknown';
|
|
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 === 'unknown'
|
|
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 = oldSchema
|
|
45
|
-
const newName = newSchema
|
|
44
|
+
const oldName = (oldSchema.getMutationType() || {}).name || 'unknown';
|
|
45
|
+
const newName = (newSchema.getMutationType() || {}).name || 'unknown';
|
|
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 === 'unknown'
|
|
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 = oldSchema
|
|
71
|
-
const newName = newSchema
|
|
70
|
+
const oldName = (oldSchema.getSubscriptionType() || {}).name || 'unknown';
|
|
71
|
+
const newName = (newSchema.getSubscriptionType() || {}).name || 'unknown';
|
|
72
72
|
return schemaSubscriptionTypeChangedFromMeta({
|
|
73
73
|
type: ChangeType.SchemaSubscriptionTypeChanged,
|
|
74
74
|
meta: {
|
|
@@ -1,5 +1,6 @@
|
|
|
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';
|
|
3
4
|
import { ChangeType, CriticalityLevel, } from './change.js';
|
|
4
5
|
function buildTypeRemovedMessage(type) {
|
|
5
6
|
return `Type '${type.removedTypeName}' was removed`;
|
|
@@ -100,7 +101,9 @@ export function typeKindChanged(oldType, newType) {
|
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
function buildTypeDescriptionChangedMessage(args) {
|
|
103
|
-
|
|
104
|
+
const oldDesc = fmt(args.oldTypeDescription);
|
|
105
|
+
const newDesc = fmt(args.newTypeDescription);
|
|
106
|
+
return `Description '${oldDesc}' on type '${args.typeName}' has changed to '${newDesc}'`;
|
|
104
107
|
}
|
|
105
108
|
export function typeDescriptionChangedFromMeta(args) {
|
|
106
109
|
return {
|
|
@@ -124,7 +127,8 @@ export function typeDescriptionChanged(oldType, newType) {
|
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
129
|
function buildTypeDescriptionRemoved(args) {
|
|
127
|
-
|
|
130
|
+
const desc = fmt(args.removedTypeDescription);
|
|
131
|
+
return `Description '${desc}' was removed from object type '${args.typeName}'`;
|
|
128
132
|
}
|
|
129
133
|
export function typeDescriptionRemovedFromMeta(args) {
|
|
130
134
|
return {
|
|
@@ -147,7 +151,8 @@ export function typeDescriptionRemoved(type) {
|
|
|
147
151
|
});
|
|
148
152
|
}
|
|
149
153
|
function buildTypeDescriptionAddedMessage(args) {
|
|
150
|
-
|
|
154
|
+
const desc = fmt(args.addedTypeDescription);
|
|
155
|
+
return `Object type '${args.typeName}' has description '${desc}'`;
|
|
151
156
|
}
|
|
152
157
|
export function typeDescriptionAddedFromMeta(args) {
|
|
153
158
|
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 =
|
|
5
|
+
const reachable = getReachableTypes(oldSchema);
|
|
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,
|
|
1
|
+
import { isEnumType, isInputObjectType, isInterfaceType, isObjectType, isScalarType, isUnionType, Kind, } from 'graphql';
|
|
2
2
|
import { compareDirectiveLists, compareLists, isNotEqual, isVoid } from '../utils/compare.js';
|
|
3
|
-
import {
|
|
3
|
+
import { 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)), Object.values(newSchema.getTypeMap()).filter(t => !isPrimitive(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(
|
|
33
|
+
compareLists(oldSchema.getDirectives(), newSchema.getDirectives(), {
|
|
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,32 +6,25 @@ 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 !== 'unknown') {
|
|
10
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, 'unknown'), change);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
schemaNode.operationTypes
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
name: nameNode(change.meta.newMutationTypeName),
|
|
21
|
-
},
|
|
12
|
+
schemaNode.operationTypes = [
|
|
13
|
+
...(schemaNode.operationTypes ?? []),
|
|
14
|
+
{
|
|
15
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
16
|
+
operation: OperationTypeNode.MUTATION,
|
|
17
|
+
type: {
|
|
18
|
+
kind: Kind.NAMED_TYPE,
|
|
19
|
+
name: nameNode(change.meta.newMutationTypeName),
|
|
22
20
|
},
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
},
|
|
22
|
+
];
|
|
25
23
|
}
|
|
26
24
|
else {
|
|
27
25
|
if (mutation.type.name.value !== change.meta.oldMutationTypeName) {
|
|
28
26
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, mutation?.type.name.value), change);
|
|
29
27
|
}
|
|
30
|
-
if (change.meta.newMutationTypeName === null) {
|
|
31
|
-
schemaNode.operationTypes =
|
|
32
|
-
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.MUTATION);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
28
|
mutation.type.name = nameNode(change.meta.newMutationTypeName);
|
|
36
29
|
}
|
|
37
30
|
}
|
|
@@ -40,32 +33,25 @@ export function schemaQueryTypeChanged(change, schemaNodes, config, _context) {
|
|
|
40
33
|
for (const schemaNode of schemaNodes) {
|
|
41
34
|
const query = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.MUTATION);
|
|
42
35
|
if (!query) {
|
|
43
|
-
if (change.meta.oldQueryTypeName !==
|
|
44
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName,
|
|
36
|
+
if (change.meta.oldQueryTypeName !== 'unknown') {
|
|
37
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, 'unknown'), change);
|
|
45
38
|
}
|
|
46
|
-
|
|
47
|
-
schemaNode.operationTypes
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
name: nameNode(change.meta.newQueryTypeName),
|
|
55
|
-
},
|
|
39
|
+
schemaNode.operationTypes = [
|
|
40
|
+
...(schemaNode.operationTypes ?? []),
|
|
41
|
+
{
|
|
42
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
43
|
+
operation: OperationTypeNode.QUERY,
|
|
44
|
+
type: {
|
|
45
|
+
kind: Kind.NAMED_TYPE,
|
|
46
|
+
name: nameNode(change.meta.newQueryTypeName),
|
|
56
47
|
},
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
},
|
|
49
|
+
];
|
|
59
50
|
}
|
|
60
51
|
else {
|
|
61
52
|
if (query.type.name.value !== change.meta.oldQueryTypeName) {
|
|
62
53
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, query?.type.name.value), change);
|
|
63
54
|
}
|
|
64
|
-
if (change.meta.newQueryTypeName === null) {
|
|
65
|
-
schemaNode.operationTypes =
|
|
66
|
-
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.QUERY);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
55
|
query.type.name = nameNode(change.meta.newQueryTypeName);
|
|
70
56
|
}
|
|
71
57
|
}
|
|
@@ -74,32 +60,25 @@ export function schemaSubscriptionTypeChanged(change, schemaNodes, config, _cont
|
|
|
74
60
|
for (const schemaNode of schemaNodes) {
|
|
75
61
|
const sub = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.SUBSCRIPTION);
|
|
76
62
|
if (!sub) {
|
|
77
|
-
if (change.meta.oldSubscriptionTypeName !==
|
|
78
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName,
|
|
63
|
+
if (change.meta.oldSubscriptionTypeName !== 'unknown') {
|
|
64
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, 'unknown'), change);
|
|
79
65
|
}
|
|
80
|
-
|
|
81
|
-
schemaNode.operationTypes
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
name: nameNode(change.meta.newSubscriptionTypeName),
|
|
89
|
-
},
|
|
66
|
+
schemaNode.operationTypes = [
|
|
67
|
+
...(schemaNode.operationTypes ?? []),
|
|
68
|
+
{
|
|
69
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
70
|
+
operation: OperationTypeNode.QUERY,
|
|
71
|
+
type: {
|
|
72
|
+
kind: Kind.NAMED_TYPE,
|
|
73
|
+
name: nameNode(change.meta.newSubscriptionTypeName),
|
|
90
74
|
},
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
},
|
|
76
|
+
];
|
|
93
77
|
}
|
|
94
78
|
else {
|
|
95
79
|
if (sub.type.name.value !== change.meta.oldSubscriptionTypeName) {
|
|
96
80
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, sub?.type.name.value), change);
|
|
97
81
|
}
|
|
98
|
-
if (change.meta.newSubscriptionTypeName === null) {
|
|
99
|
-
schemaNode.operationTypes =
|
|
100
|
-
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.SUBSCRIPTION);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
82
|
sub.type.name = nameNode(change.meta.newSubscriptionTypeName);
|
|
104
83
|
}
|
|
105
84
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/action",
|
|
3
|
-
"version": "5.0.16
|
|
3
|
+
"version": "5.0.16",
|
|
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.
|
|
14
|
+
"@graphql-inspector/core": "7.0.4"
|
|
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;
|
|
495
|
+
newQueryTypeName: string;
|
|
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;
|
|
502
|
+
newMutationTypeName: string;
|
|
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;
|
|
509
|
+
newSubscriptionTypeName: string;
|
|
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;
|
|
495
|
+
newQueryTypeName: string;
|
|
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;
|
|
502
|
+
newMutationTypeName: string;
|
|
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;
|
|
509
|
+
newSubscriptionTypeName: string;
|
|
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;
|
|
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;
|
|
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;
|
|
11
|
+
newQueryTypeName: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema
|
|
14
|
+
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): 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;
|
|
23
|
+
newMutationTypeName: string;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema
|
|
26
|
+
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): 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;
|
|
35
|
+
newSubscriptionTypeName: string;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema
|
|
38
|
+
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): 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;
|
|
11
|
+
newQueryTypeName: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema
|
|
14
|
+
export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): 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;
|
|
23
|
+
newMutationTypeName: string;
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema
|
|
26
|
+
export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): 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;
|
|
35
|
+
newSubscriptionTypeName: string;
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema
|
|
38
|
+
export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): 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
|
|
9
|
+
export declare function diff(oldSchema: GraphQLSchema, newSchema: GraphQLSchema, 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
|
|
9
|
+
export declare function diff(oldSchema: GraphQLSchema, newSchema: GraphQLSchema, 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;
|
|
6
|
+
newSchema: GraphQLSchema;
|
|
7
7
|
config: TConfig;
|
|
8
8
|
}) => Change[] | Promise<Change[]>;
|