@graphql-inspector/diff-command 0.0.0-canary.36985fe → 0.0.0-canary.36b26d2
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/index.d.ts +1 -0
- package/index.js +12 -13
- package/index.mjs +12 -13
- package/package.json +5 -5
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -10,9 +10,7 @@ const fs = require('fs');
|
|
|
10
10
|
|
|
11
11
|
function handler(input) {
|
|
12
12
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
const onComplete = input.onComplete
|
|
14
|
-
? resolveCompletionHandler(input.onComplete)
|
|
15
|
-
: failOnBreakingChanges;
|
|
13
|
+
const onComplete = input.onComplete ? resolveCompletionHandler(input.onComplete) : failOnBreakingChanges;
|
|
16
14
|
const rules = input.rules
|
|
17
15
|
? input.rules
|
|
18
16
|
.filter(isString)
|
|
@@ -23,7 +21,7 @@ function handler(input) {
|
|
|
23
21
|
}
|
|
24
22
|
return rule;
|
|
25
23
|
})
|
|
26
|
-
.filter(
|
|
24
|
+
.filter(f => f)
|
|
27
25
|
: [];
|
|
28
26
|
const changes = yield core.diff(input.oldSchema, input.newSchema, rules, {
|
|
29
27
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
@@ -33,9 +31,9 @@ function handler(input) {
|
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
33
|
logger.Logger.log(`\nDetected the following changes (${changes.length}) between schemas:\n`);
|
|
36
|
-
const breakingChanges = changes.filter(
|
|
37
|
-
const dangerousChanges = changes.filter(
|
|
38
|
-
const nonBreakingChanges = changes.filter(
|
|
34
|
+
const breakingChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.Breaking);
|
|
35
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.Dangerous);
|
|
36
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === core.CriticalityLevel.NonBreaking);
|
|
39
37
|
if (breakingChanges.length) {
|
|
40
38
|
reportBreakingChanges(breakingChanges);
|
|
41
39
|
}
|
|
@@ -48,7 +46,7 @@ function handler(input) {
|
|
|
48
46
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
|
-
const index = commands.createCommand(
|
|
49
|
+
const index = commands.createCommand(api => {
|
|
52
50
|
const { loaders } = api;
|
|
53
51
|
return {
|
|
54
52
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -93,12 +91,12 @@ const index = commands.createCommand((api) => {
|
|
|
93
91
|
const oldSchemaHeaders = Object.assign(Object.assign({}, (headers !== null && headers !== void 0 ? headers : {})), (leftHeaders !== null && leftHeaders !== void 0 ? leftHeaders : {}));
|
|
94
92
|
const newSchemaHeaders = Object.assign(Object.assign({}, (headers !== null && headers !== void 0 ? headers : {})), (rightHeaders !== null && rightHeaders !== void 0 ? rightHeaders : {}));
|
|
95
93
|
const oldSchema = yield loaders.loadSchema(oldSchemaPointer, {
|
|
96
|
-
oldSchemaHeaders,
|
|
94
|
+
headers: oldSchemaHeaders,
|
|
97
95
|
token,
|
|
98
96
|
method,
|
|
99
97
|
}, apolloFederation, aws);
|
|
100
98
|
const newSchema = yield loaders.loadSchema(newSchemaPointer, {
|
|
101
|
-
newSchemaHeaders,
|
|
99
|
+
headers: newSchemaHeaders,
|
|
102
100
|
token,
|
|
103
101
|
method,
|
|
104
102
|
}, apolloFederation, aws);
|
|
@@ -107,6 +105,7 @@ const index = commands.createCommand((api) => {
|
|
|
107
105
|
newSchema,
|
|
108
106
|
rules: args.rule,
|
|
109
107
|
onComplete: args.onComplete,
|
|
108
|
+
onUsage: args.onUsage,
|
|
110
109
|
});
|
|
111
110
|
}
|
|
112
111
|
catch (error) {
|
|
@@ -133,21 +132,21 @@ function sortChanges(changes) {
|
|
|
133
132
|
function reportBreakingChanges(changes) {
|
|
134
133
|
const label = logger.symbols.error;
|
|
135
134
|
const sorted = sortChanges(changes);
|
|
136
|
-
sorted.forEach(
|
|
135
|
+
sorted.forEach(change => {
|
|
137
136
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
function reportDangerousChanges(changes) {
|
|
141
140
|
const label = logger.symbols.warning;
|
|
142
141
|
const sorted = sortChanges(changes);
|
|
143
|
-
sorted.forEach(
|
|
142
|
+
sorted.forEach(change => {
|
|
144
143
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
145
144
|
});
|
|
146
145
|
}
|
|
147
146
|
function reportNonBreakingChanges(changes) {
|
|
148
147
|
const label = logger.symbols.success;
|
|
149
148
|
const sorted = sortChanges(changes);
|
|
150
|
-
sorted.forEach(
|
|
149
|
+
sorted.forEach(change => {
|
|
151
150
|
logger.Logger.log(`${label} ${logger.bolderize(change.message)}`);
|
|
152
151
|
});
|
|
153
152
|
}
|
package/index.mjs
CHANGED
|
@@ -6,9 +6,7 @@ import { existsSync } from 'fs';
|
|
|
6
6
|
|
|
7
7
|
function handler(input) {
|
|
8
8
|
return __awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
const onComplete = input.onComplete
|
|
10
|
-
? resolveCompletionHandler(input.onComplete)
|
|
11
|
-
: failOnBreakingChanges;
|
|
9
|
+
const onComplete = input.onComplete ? resolveCompletionHandler(input.onComplete) : failOnBreakingChanges;
|
|
12
10
|
const rules = input.rules
|
|
13
11
|
? input.rules
|
|
14
12
|
.filter(isString)
|
|
@@ -19,7 +17,7 @@ function handler(input) {
|
|
|
19
17
|
}
|
|
20
18
|
return rule;
|
|
21
19
|
})
|
|
22
|
-
.filter(
|
|
20
|
+
.filter(f => f)
|
|
23
21
|
: [];
|
|
24
22
|
const changes = yield diff(input.oldSchema, input.newSchema, rules, {
|
|
25
23
|
checkUsage: input.onUsage ? resolveUsageHandler(input.onUsage) : undefined,
|
|
@@ -29,9 +27,9 @@ function handler(input) {
|
|
|
29
27
|
return;
|
|
30
28
|
}
|
|
31
29
|
Logger.log(`\nDetected the following changes (${changes.length}) between schemas:\n`);
|
|
32
|
-
const breakingChanges = changes.filter(
|
|
33
|
-
const dangerousChanges = changes.filter(
|
|
34
|
-
const nonBreakingChanges = changes.filter(
|
|
30
|
+
const breakingChanges = changes.filter(change => change.criticality.level === CriticalityLevel.Breaking);
|
|
31
|
+
const dangerousChanges = changes.filter(change => change.criticality.level === CriticalityLevel.Dangerous);
|
|
32
|
+
const nonBreakingChanges = changes.filter(change => change.criticality.level === CriticalityLevel.NonBreaking);
|
|
35
33
|
if (breakingChanges.length) {
|
|
36
34
|
reportBreakingChanges(breakingChanges);
|
|
37
35
|
}
|
|
@@ -44,7 +42,7 @@ function handler(input) {
|
|
|
44
42
|
onComplete({ breakingChanges, dangerousChanges, nonBreakingChanges });
|
|
45
43
|
});
|
|
46
44
|
}
|
|
47
|
-
const index = createCommand(
|
|
45
|
+
const index = createCommand(api => {
|
|
48
46
|
const { loaders } = api;
|
|
49
47
|
return {
|
|
50
48
|
command: 'diff <oldSchema> <newSchema>',
|
|
@@ -89,12 +87,12 @@ const index = createCommand((api) => {
|
|
|
89
87
|
const oldSchemaHeaders = Object.assign(Object.assign({}, (headers !== null && headers !== void 0 ? headers : {})), (leftHeaders !== null && leftHeaders !== void 0 ? leftHeaders : {}));
|
|
90
88
|
const newSchemaHeaders = Object.assign(Object.assign({}, (headers !== null && headers !== void 0 ? headers : {})), (rightHeaders !== null && rightHeaders !== void 0 ? rightHeaders : {}));
|
|
91
89
|
const oldSchema = yield loaders.loadSchema(oldSchemaPointer, {
|
|
92
|
-
oldSchemaHeaders,
|
|
90
|
+
headers: oldSchemaHeaders,
|
|
93
91
|
token,
|
|
94
92
|
method,
|
|
95
93
|
}, apolloFederation, aws);
|
|
96
94
|
const newSchema = yield loaders.loadSchema(newSchemaPointer, {
|
|
97
|
-
newSchemaHeaders,
|
|
95
|
+
headers: newSchemaHeaders,
|
|
98
96
|
token,
|
|
99
97
|
method,
|
|
100
98
|
}, apolloFederation, aws);
|
|
@@ -103,6 +101,7 @@ const index = createCommand((api) => {
|
|
|
103
101
|
newSchema,
|
|
104
102
|
rules: args.rule,
|
|
105
103
|
onComplete: args.onComplete,
|
|
104
|
+
onUsage: args.onUsage,
|
|
106
105
|
});
|
|
107
106
|
}
|
|
108
107
|
catch (error) {
|
|
@@ -129,21 +128,21 @@ function sortChanges(changes) {
|
|
|
129
128
|
function reportBreakingChanges(changes) {
|
|
130
129
|
const label = symbols.error;
|
|
131
130
|
const sorted = sortChanges(changes);
|
|
132
|
-
sorted.forEach(
|
|
131
|
+
sorted.forEach(change => {
|
|
133
132
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
134
133
|
});
|
|
135
134
|
}
|
|
136
135
|
function reportDangerousChanges(changes) {
|
|
137
136
|
const label = symbols.warning;
|
|
138
137
|
const sorted = sortChanges(changes);
|
|
139
|
-
sorted.forEach(
|
|
138
|
+
sorted.forEach(change => {
|
|
140
139
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
141
140
|
});
|
|
142
141
|
}
|
|
143
142
|
function reportNonBreakingChanges(changes) {
|
|
144
143
|
const label = symbols.success;
|
|
145
144
|
const sorted = sortChanges(changes);
|
|
146
|
-
sorted.forEach(
|
|
145
|
+
sorted.forEach(change => {
|
|
147
146
|
Logger.log(`${label} ${bolderize(change.message)}`);
|
|
148
147
|
});
|
|
149
148
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/diff-command",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.36b26d2",
|
|
4
4
|
"description": "Compare GraphQL Schemas",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0"
|
|
7
|
+
"graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-inspector/commands": "0.0.0-canary.
|
|
11
|
-
"@graphql-inspector/core": "0.0.0-canary.
|
|
12
|
-
"@graphql-inspector/logger": "0.0.0-canary.
|
|
10
|
+
"@graphql-inspector/commands": "0.0.0-canary.36b26d2",
|
|
11
|
+
"@graphql-inspector/core": "0.0.0-canary.36b26d2",
|
|
12
|
+
"@graphql-inspector/logger": "0.0.0-canary.36b26d2",
|
|
13
13
|
"tslib": "^2.0.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|