@graphql-inspector/core 3.1.0 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +6 -6
  2. package/dist/LICENSE +21 -0
  3. package/dist/README.md +55 -0
  4. package/{ast → dist/ast}/document.d.ts +0 -0
  5. package/{coverage → dist/coverage}/index.d.ts +0 -0
  6. package/{coverage → dist/coverage}/output/json.d.ts +0 -0
  7. package/{diff → dist/diff}/argument.d.ts +0 -0
  8. package/{diff → dist/diff}/changes/argument.d.ts +0 -0
  9. package/{diff → dist/diff}/changes/change.d.ts +0 -0
  10. package/{diff → dist/diff}/changes/directive.d.ts +0 -0
  11. package/{diff → dist/diff}/changes/enum.d.ts +0 -0
  12. package/{diff → dist/diff}/changes/field.d.ts +0 -0
  13. package/{diff → dist/diff}/changes/input.d.ts +0 -0
  14. package/{diff → dist/diff}/changes/object.d.ts +0 -0
  15. package/{diff → dist/diff}/changes/schema.d.ts +0 -0
  16. package/{diff → dist/diff}/changes/type.d.ts +0 -0
  17. package/{diff → dist/diff}/changes/union.d.ts +0 -0
  18. package/{diff → dist/diff}/directive.d.ts +0 -0
  19. package/{diff → dist/diff}/enum.d.ts +0 -0
  20. package/{diff → dist/diff}/field.d.ts +0 -0
  21. package/{diff → dist/diff}/index.d.ts +0 -0
  22. package/{diff → dist/diff}/input.d.ts +0 -0
  23. package/{diff → dist/diff}/interface.d.ts +0 -0
  24. package/{diff → dist/diff}/object.d.ts +0 -0
  25. package/{diff → dist/diff}/onComplete/types.d.ts +0 -0
  26. package/{diff → dist/diff}/rules/config.d.ts +0 -0
  27. package/{diff → dist/diff}/rules/consider-usage.d.ts +0 -0
  28. package/{diff → dist/diff}/rules/dangerous-breaking.d.ts +0 -0
  29. package/{diff → dist/diff}/rules/ignore-description-changes.d.ts +0 -0
  30. package/{diff → dist/diff}/rules/index.d.ts +1 -0
  31. package/{diff → dist/diff}/rules/safe-unreachable.d.ts +0 -0
  32. package/{diff → dist/diff}/rules/suppress-removal-of-deprecated-field.d.ts +0 -0
  33. package/{diff → dist/diff}/rules/types.d.ts +0 -0
  34. package/{diff → dist/diff}/schema.d.ts +0 -0
  35. package/{diff → dist/diff}/union.d.ts +0 -0
  36. package/{index.d.ts → dist/index.d.ts} +1 -1
  37. package/{index.js → dist/index.js} +104 -10
  38. package/{index.mjs → dist/index.mjs} +105 -11
  39. package/dist/package.json +46 -0
  40. package/{similar → dist/similar}/index.d.ts +0 -0
  41. package/{utils → dist/utils}/apollo.d.ts +0 -0
  42. package/{utils → dist/utils}/compare.d.ts +0 -1
  43. package/{utils → dist/utils}/graphql.d.ts +0 -0
  44. package/{utils → dist/utils}/isDeprecated.d.ts +1 -1
  45. package/{utils → dist/utils}/path.d.ts +0 -0
  46. package/{utils → dist/utils}/string.d.ts +0 -0
  47. package/{validate → dist/validate}/index.d.ts +0 -0
  48. package/{validate → dist/validate}/query-depth.d.ts +0 -0
  49. package/package.json +35 -29
  50. package/utils/testing.ts +11 -0
package/README.md CHANGED
@@ -36,17 +36,17 @@ import {
36
36
  Change,
37
37
  InvalidDocument,
38
38
  SimilarMap,
39
- SchemaCoverage,
40
- } from '@graphql-inspector/core';
39
+ SchemaCoverage
40
+ } from '@graphql-inspector/core'
41
41
 
42
42
  // diff
43
- const changes: Change[] = diff(schemaA, schemaB);
43
+ const changes: Change[] = diff(schemaA, schemaB)
44
44
  // validate
45
- const invalid: InvalidDocument[] = validate(documentsGlob, schema);
45
+ const invalid: InvalidDocument[] = validate(documentsGlob, schema)
46
46
  // similar
47
- const similar: SimilarMap = similar(schema, typename, threshold);
47
+ const similar: SimilarMap = similar(schema, typename, threshold)
48
48
  // coverage
49
- const schemaCoverage: SchemaCoverage = coverage(schema, documents);
49
+ const schemaCoverage: SchemaCoverage = coverage(schema, documents)
50
50
  // ...
51
51
  ```
52
52
 
package/dist/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Kamil Kisiela
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # GraphQL Inspector
2
+
3
+ [![CircleCI](https://circleci.com/gh/kamilkisiela/graphql-inspector.svg?style=shield&circle-token=d1cd06aba321ee2b7bf8bd2041104643639463b0)](https://circleci.com/gh/kamilkisiela/graphql-inspector)
4
+ [![npm version](https://badge.fury.io/js/@graphql-inspector/core.svg)](https://npmjs.com/package/@graphql-inspector/core)
5
+
6
+ **GraphQL Inspector** ouputs a list of changes between two GraphQL schemas. Every change is precisely explained and marked as breaking, non-breaking or dangerous.
7
+ It helps you validate documents and fragments against a schema and even find similar or duplicated types.
8
+
9
+ ## Features
10
+
11
+ Major features:
12
+
13
+ - **Compares schemas**
14
+ - **Finds breaking or dangerous changes**
15
+ - **Validates documents against a schema**
16
+ - **Finds similar / duplicated types**
17
+ - **Schema coverage based on documents**
18
+ - **Serves a GraphQL server with faked data and GraphQL Playground**
19
+
20
+ GraphQL Inspector has a **CLI** and also a **programatic API**, so you can use it however you want to and even build tools on top of it.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ yarn add @graphql-inspector/core
26
+ ```
27
+
28
+ ## Examples
29
+
30
+ ```typescript
31
+ import {
32
+ diff,
33
+ validate,
34
+ similar,
35
+ coverage,
36
+ Change,
37
+ InvalidDocument,
38
+ SimilarMap,
39
+ SchemaCoverage
40
+ } from '@graphql-inspector/core'
41
+
42
+ // diff
43
+ const changes: Change[] = diff(schemaA, schemaB)
44
+ // validate
45
+ const invalid: InvalidDocument[] = validate(documentsGlob, schema)
46
+ // similar
47
+ const similar: SimilarMap = similar(schema, typename, threshold)
48
+ // coverage
49
+ const schemaCoverage: SchemaCoverage = coverage(schema, documents)
50
+ // ...
51
+ ```
52
+
53
+ ## License
54
+
55
+ [MIT](https://github.com/kamilkisiela/graphql-inspector/blob/master/LICENSE) © Kamil Kisiela
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,3 +2,4 @@ export * from './dangerous-breaking';
2
2
  export * from './suppress-removal-of-deprecated-field';
3
3
  export * from './ignore-description-changes';
4
4
  export * from './consider-usage';
5
+ export * from './safe-unreachable';
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- export { diff, DiffRule, Rule, CompletionArgs, CompletionHandler, UsageHandler } from './diff';
1
+ export { diff, DiffRule, Rule, CompletionArgs, CompletionHandler, UsageHandler, } from './diff';
2
2
  export { validate, InvalidDocument } from './validate';
3
3
  export { similar, SimilarMap } from './similar';
4
4
  export * from './coverage';
@@ -20,7 +20,21 @@ function isEqual(a, b) {
20
20
  if (a.length !== b.length)
21
21
  return false;
22
22
  for (var index = 0; index < a.length; index++) {
23
- if (a[index] !== b[index]) {
23
+ if (!isEqual(a[index], b[index])) {
24
+ return false;
25
+ }
26
+ }
27
+ return true;
28
+ }
29
+ if (typeof a === 'object' && typeof b === 'object') {
30
+ const aRecord = a;
31
+ const bRecord = b;
32
+ const aKeys = Object.keys(aRecord);
33
+ const bKeys = Object.keys(bRecord);
34
+ if (aKeys.length !== bKeys.length)
35
+ return false;
36
+ for (const key of aKeys) {
37
+ if (!isEqual(aRecord[key], bRecord[key])) {
24
38
  return false;
25
39
  }
26
40
  }
@@ -35,7 +49,7 @@ function isVoid(a) {
35
49
  return typeof a === 'undefined' || a === null;
36
50
  }
37
51
  function diffArrays(a, b) {
38
- return a.filter((c) => !b.some((d) => d === c));
52
+ return a.filter((c) => !b.some((d) => isEqual(d, c)));
39
53
  }
40
54
  function compareLists(oldList, newList, callbacks) {
41
55
  const oldMap = keyMap(oldList, ({ name }) => name);
@@ -86,7 +100,7 @@ function isDeprecated(fieldOrEnumValue) {
86
100
  if (fieldOrEnumValue.deprecationReason != null) {
87
101
  return true;
88
102
  }
89
- if ((_b = (_a = fieldOrEnumValue.astNode) === null || _a === void 0 ? void 0 : _a.directives) === null || _b === void 0 ? void 0 : _b.some(directive => directive.name.value === "deprecated")) {
103
+ if ((_b = (_a = fieldOrEnumValue.astNode) === null || _a === void 0 ? void 0 : _a.directives) === null || _b === void 0 ? void 0 : _b.some((directive) => directive.name.value === 'deprecated')) {
90
104
  return true;
91
105
  }
92
106
  return false;
@@ -204,6 +218,75 @@ function removeDirectives(node, directiveNames) {
204
218
  }
205
219
  return node;
206
220
  }
221
+ function getReachableTypes(schema) {
222
+ const reachableTypes = new Set();
223
+ const collect = (type) => {
224
+ const typeName = type.name;
225
+ if (reachableTypes.has(typeName)) {
226
+ return;
227
+ }
228
+ reachableTypes.add(typeName);
229
+ if (graphql.isScalarType(type)) {
230
+ return;
231
+ }
232
+ else if (graphql.isInterfaceType(type) || graphql.isObjectType(type)) {
233
+ if (graphql.isInterfaceType(type)) {
234
+ const { objects, interfaces } = schema.getImplementations(type);
235
+ for (const child of objects) {
236
+ collect(child);
237
+ }
238
+ for (const child of interfaces) {
239
+ collect(child);
240
+ }
241
+ }
242
+ const fields = type.getFields();
243
+ for (const fieldName in fields) {
244
+ const field = fields[fieldName];
245
+ collect(resolveOutputType(field.type));
246
+ const args = field.args;
247
+ for (const argName in args) {
248
+ const arg = args[argName];
249
+ collect(resolveInputType(arg.type));
250
+ }
251
+ }
252
+ }
253
+ else if (graphql.isUnionType(type)) {
254
+ const types = type.getTypes();
255
+ for (const child of types) {
256
+ collect(child);
257
+ }
258
+ }
259
+ else if (graphql.isInputObjectType(type)) {
260
+ const fields = type.getFields();
261
+ for (const fieldName in fields) {
262
+ const field = fields[fieldName];
263
+ collect(resolveInputType(field.type));
264
+ }
265
+ }
266
+ };
267
+ for (const type of [
268
+ schema.getQueryType(),
269
+ schema.getMutationType(),
270
+ schema.getSubscriptionType(),
271
+ ]) {
272
+ if (type) {
273
+ collect(type);
274
+ }
275
+ }
276
+ return reachableTypes;
277
+ }
278
+ function resolveOutputType(output) {
279
+ if (graphql.isListType(output) || graphql.isNonNullType(output)) {
280
+ return resolveOutputType(output.ofType);
281
+ }
282
+ return output;
283
+ }
284
+ function resolveInputType(input) {
285
+ if (graphql.isListType(input) || graphql.isNonNullType(input)) {
286
+ return resolveInputType(input.ofType);
287
+ }
288
+ return input;
289
+ }
207
290
 
208
291
  (function (ChangeType) {
209
292
  // Argument
@@ -573,7 +656,7 @@ function changesInEnum(oldEnum, newEnum, addChange) {
573
656
  addChange(enumValueDeprecationReasonChanged(newEnum, oldValue, newValue));
574
657
  }
575
658
  }
576
- }
659
+ },
577
660
  });
578
661
  }
579
662
 
@@ -970,10 +1053,7 @@ function wordLetterPairs(str) {
970
1053
  return flattenDeep(pairs);
971
1054
  }
972
1055
  function safeString(obj) {
973
- if (obj != null && typeof obj.toString === 'function') {
974
- return `${obj}`;
975
- }
976
- return inspect(obj);
1056
+ return inspect(obj).replace(/\[Object\: null prototype\] /g, '');
977
1057
  }
978
1058
 
979
1059
  function fieldArgumentDescriptionChanged(type, field, oldArg, newArg) {
@@ -1081,7 +1161,7 @@ function changesInField(type, oldField, newField, addChange) {
1081
1161
  },
1082
1162
  onMutual(arg) {
1083
1163
  changesInArgument(type, oldField, arg.oldVersion, arg.newVersion, addChange);
1084
- }
1164
+ },
1085
1165
  });
1086
1166
  }
1087
1167
 
@@ -1344,12 +1424,26 @@ const considerUsage = ({ changes, config, }) => tslib.__awaiter(void 0, void 0,
1344
1424
  });
1345
1425
  });
1346
1426
 
1427
+ const safeUnreachable = ({ changes, oldSchema }) => {
1428
+ const reachable = getReachableTypes(oldSchema);
1429
+ return changes.map((change) => {
1430
+ if (change.criticality.level === exports.CriticalityLevel.Breaking && change.path) {
1431
+ const [typeName] = parsePath(change.path);
1432
+ if (!reachable.has(typeName)) {
1433
+ return Object.assign(Object.assign({}, change), { criticality: Object.assign(Object.assign({}, change.criticality), { level: exports.CriticalityLevel.NonBreaking }), message: 'Unreachable from root' });
1434
+ }
1435
+ }
1436
+ return change;
1437
+ });
1438
+ };
1439
+
1347
1440
  const rules = /*#__PURE__*/Object.freeze({
1348
1441
  __proto__: null,
1349
1442
  dangerousBreaking: dangerousBreaking,
1350
1443
  suppressRemovalOfDeprecatedField: suppressRemovalOfDeprecatedField,
1351
1444
  ignoreDescriptionChanges: ignoreDescriptionChanges,
1352
- considerUsage: considerUsage
1445
+ considerUsage: considerUsage,
1446
+ safeUnreachable: safeUnreachable
1353
1447
  });
1354
1448
 
1355
1449
  const DiffRule = rules;
@@ -1,5 +1,5 @@
1
1
  import { __awaiter } from 'tslib';
2
- import { Kind, TypeInfo, visit, visitWithTypeInfo, GraphQLError, getNamedType, isWrappingType, isListType, isNonNullType, isInterfaceType, isEnumType, isUnionType, isInputObjectType, isObjectType, isScalarType, parse, extendSchema, print, validate as validate$1, printType } from 'graphql';
2
+ import { Kind, TypeInfo, visit, visitWithTypeInfo, GraphQLError, getNamedType, isScalarType, isInterfaceType, isObjectType, isUnionType, isInputObjectType, isListType, isNonNullType, isWrappingType, isEnumType, parse, extendSchema, print, validate as validate$1, printType } from 'graphql';
3
3
  import inspect from 'object-inspect';
4
4
  import { DepGraph } from 'dependency-graph';
5
5
 
@@ -14,7 +14,21 @@ function isEqual(a, b) {
14
14
  if (a.length !== b.length)
15
15
  return false;
16
16
  for (var index = 0; index < a.length; index++) {
17
- if (a[index] !== b[index]) {
17
+ if (!isEqual(a[index], b[index])) {
18
+ return false;
19
+ }
20
+ }
21
+ return true;
22
+ }
23
+ if (typeof a === 'object' && typeof b === 'object') {
24
+ const aRecord = a;
25
+ const bRecord = b;
26
+ const aKeys = Object.keys(aRecord);
27
+ const bKeys = Object.keys(bRecord);
28
+ if (aKeys.length !== bKeys.length)
29
+ return false;
30
+ for (const key of aKeys) {
31
+ if (!isEqual(aRecord[key], bRecord[key])) {
18
32
  return false;
19
33
  }
20
34
  }
@@ -29,7 +43,7 @@ function isVoid(a) {
29
43
  return typeof a === 'undefined' || a === null;
30
44
  }
31
45
  function diffArrays(a, b) {
32
- return a.filter((c) => !b.some((d) => d === c));
46
+ return a.filter((c) => !b.some((d) => isEqual(d, c)));
33
47
  }
34
48
  function compareLists(oldList, newList, callbacks) {
35
49
  const oldMap = keyMap(oldList, ({ name }) => name);
@@ -80,7 +94,7 @@ function isDeprecated(fieldOrEnumValue) {
80
94
  if (fieldOrEnumValue.deprecationReason != null) {
81
95
  return true;
82
96
  }
83
- if ((_b = (_a = fieldOrEnumValue.astNode) === null || _a === void 0 ? void 0 : _a.directives) === null || _b === void 0 ? void 0 : _b.some(directive => directive.name.value === "deprecated")) {
97
+ if ((_b = (_a = fieldOrEnumValue.astNode) === null || _a === void 0 ? void 0 : _a.directives) === null || _b === void 0 ? void 0 : _b.some((directive) => directive.name.value === 'deprecated')) {
84
98
  return true;
85
99
  }
86
100
  return false;
@@ -198,6 +212,75 @@ function removeDirectives(node, directiveNames) {
198
212
  }
199
213
  return node;
200
214
  }
215
+ function getReachableTypes(schema) {
216
+ const reachableTypes = new Set();
217
+ const collect = (type) => {
218
+ const typeName = type.name;
219
+ if (reachableTypes.has(typeName)) {
220
+ return;
221
+ }
222
+ reachableTypes.add(typeName);
223
+ if (isScalarType(type)) {
224
+ return;
225
+ }
226
+ else if (isInterfaceType(type) || isObjectType(type)) {
227
+ if (isInterfaceType(type)) {
228
+ const { objects, interfaces } = schema.getImplementations(type);
229
+ for (const child of objects) {
230
+ collect(child);
231
+ }
232
+ for (const child of interfaces) {
233
+ collect(child);
234
+ }
235
+ }
236
+ const fields = type.getFields();
237
+ for (const fieldName in fields) {
238
+ const field = fields[fieldName];
239
+ collect(resolveOutputType(field.type));
240
+ const args = field.args;
241
+ for (const argName in args) {
242
+ const arg = args[argName];
243
+ collect(resolveInputType(arg.type));
244
+ }
245
+ }
246
+ }
247
+ else if (isUnionType(type)) {
248
+ const types = type.getTypes();
249
+ for (const child of types) {
250
+ collect(child);
251
+ }
252
+ }
253
+ else if (isInputObjectType(type)) {
254
+ const fields = type.getFields();
255
+ for (const fieldName in fields) {
256
+ const field = fields[fieldName];
257
+ collect(resolveInputType(field.type));
258
+ }
259
+ }
260
+ };
261
+ for (const type of [
262
+ schema.getQueryType(),
263
+ schema.getMutationType(),
264
+ schema.getSubscriptionType(),
265
+ ]) {
266
+ if (type) {
267
+ collect(type);
268
+ }
269
+ }
270
+ return reachableTypes;
271
+ }
272
+ function resolveOutputType(output) {
273
+ if (isListType(output) || isNonNullType(output)) {
274
+ return resolveOutputType(output.ofType);
275
+ }
276
+ return output;
277
+ }
278
+ function resolveInputType(input) {
279
+ if (isListType(input) || isNonNullType(input)) {
280
+ return resolveInputType(input.ofType);
281
+ }
282
+ return input;
283
+ }
201
284
 
202
285
  var ChangeType;
203
286
  (function (ChangeType) {
@@ -569,7 +652,7 @@ function changesInEnum(oldEnum, newEnum, addChange) {
569
652
  addChange(enumValueDeprecationReasonChanged(newEnum, oldValue, newValue));
570
653
  }
571
654
  }
572
- }
655
+ },
573
656
  });
574
657
  }
575
658
 
@@ -966,10 +1049,7 @@ function wordLetterPairs(str) {
966
1049
  return flattenDeep(pairs);
967
1050
  }
968
1051
  function safeString(obj) {
969
- if (obj != null && typeof obj.toString === 'function') {
970
- return `${obj}`;
971
- }
972
- return inspect(obj);
1052
+ return inspect(obj).replace(/\[Object\: null prototype\] /g, '');
973
1053
  }
974
1054
 
975
1055
  function fieldArgumentDescriptionChanged(type, field, oldArg, newArg) {
@@ -1077,7 +1157,7 @@ function changesInField(type, oldField, newField, addChange) {
1077
1157
  },
1078
1158
  onMutual(arg) {
1079
1159
  changesInArgument(type, oldField, arg.oldVersion, arg.newVersion, addChange);
1080
- }
1160
+ },
1081
1161
  });
1082
1162
  }
1083
1163
 
@@ -1340,12 +1420,26 @@ const considerUsage = ({ changes, config, }) => __awaiter(void 0, void 0, void 0
1340
1420
  });
1341
1421
  });
1342
1422
 
1423
+ const safeUnreachable = ({ changes, oldSchema }) => {
1424
+ const reachable = getReachableTypes(oldSchema);
1425
+ return changes.map((change) => {
1426
+ if (change.criticality.level === CriticalityLevel.Breaking && change.path) {
1427
+ const [typeName] = parsePath(change.path);
1428
+ if (!reachable.has(typeName)) {
1429
+ return Object.assign(Object.assign({}, change), { criticality: Object.assign(Object.assign({}, change.criticality), { level: CriticalityLevel.NonBreaking }), message: 'Unreachable from root' });
1430
+ }
1431
+ }
1432
+ return change;
1433
+ });
1434
+ };
1435
+
1343
1436
  const rules = /*#__PURE__*/Object.freeze({
1344
1437
  __proto__: null,
1345
1438
  dangerousBreaking: dangerousBreaking,
1346
1439
  suppressRemovalOfDeprecatedField: suppressRemovalOfDeprecatedField,
1347
1440
  ignoreDescriptionChanges: ignoreDescriptionChanges,
1348
- considerUsage: considerUsage
1441
+ considerUsage: considerUsage,
1442
+ safeUnreachable: safeUnreachable
1349
1443
  });
1350
1444
 
1351
1445
  const DiffRule = rules;
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@graphql-inspector/core",
3
+ "version": "3.1.3",
4
+ "description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
5
+ "sideEffects": false,
6
+ "peerDependencies": {
7
+ "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
8
+ },
9
+ "dependencies": {
10
+ "dependency-graph": "0.11.0",
11
+ "object-inspect": "1.10.3",
12
+ "tslib": "^2.0.0"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "kamilkisiela/graphql-inspector",
17
+ "directory": "packages/core"
18
+ },
19
+ "keywords": [
20
+ "graphql",
21
+ "graphql-inspector",
22
+ "tools"
23
+ ],
24
+ "author": {
25
+ "name": "Kamil Kisiela",
26
+ "email": "kamil.kisiela@gmail.com",
27
+ "url": "https://github.com/kamilkisiela"
28
+ },
29
+ "license": "MIT",
30
+ "main": "index.js",
31
+ "module": "index.mjs",
32
+ "typings": "index.d.ts",
33
+ "typescript": {
34
+ "definition": "index.d.ts"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "require": "./index.js",
39
+ "import": "./index.mjs"
40
+ },
41
+ "./*": {
42
+ "require": "./*.js",
43
+ "import": "./*.mjs"
44
+ }
45
+ }
46
+ }
File without changes
File without changes
@@ -3,7 +3,6 @@ export declare function isEqual<T>(a: T, b: T): boolean;
3
3
  export declare function isNotEqual<T>(a: T, b: T): boolean;
4
4
  export declare function isVoid<T>(a: T): boolean;
5
5
  export declare function diffArrays<T>(a: T[] | readonly T[], b: T[] | readonly T[]): T[];
6
- export declare function unionArrays<T>(a: T[] | readonly T[], b: T[] | readonly T[]): T[];
7
6
  export declare function compareLists<T extends {
8
7
  name: string;
9
8
  }>(oldList: readonly T[], newList: readonly T[], callbacks?: {
File without changes
@@ -1,2 +1,2 @@
1
- import { GraphQLEnumValue, GraphQLField } from "graphql";
1
+ import { GraphQLEnumValue, GraphQLField } from 'graphql';
2
2
  export declare function isDeprecated(fieldOrEnumValue: GraphQLField<any, any> | GraphQLEnumValue): boolean;
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,46 +1,52 @@
1
1
  {
2
2
  "name": "@graphql-inspector/core",
3
- "version": "3.1.0",
3
+ "version": "3.1.3",
4
4
  "description": "Tooling for GraphQL. Compare GraphQL Schemas, check documents, find breaking changes, find similar types.",
5
- "sideEffects": false,
6
- "peerDependencies": {
7
- "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
8
- },
9
- "dependencies": {
10
- "dependency-graph": "0.11.0",
11
- "object-inspect": "1.10.3",
12
- "tslib": "^2.0.0"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "kamilkisiela/graphql-inspector",
17
- "directory": "packages/core"
18
- },
19
5
  "keywords": [
20
6
  "graphql",
21
7
  "graphql-inspector",
22
8
  "tools"
23
9
  ],
10
+ "sideEffects": false,
11
+ "main": "dist/index.js",
12
+ "module": "dist/index.mjs",
13
+ "exports": {
14
+ ".": {
15
+ "require": "./dist/index.js",
16
+ "import": "./dist/index.mjs"
17
+ },
18
+ "./*": {
19
+ "require": "./dist/*.js",
20
+ "import": "./dist/*.mjs"
21
+ }
22
+ },
23
+ "typings": "dist/index.d.ts",
24
+ "typescript": {
25
+ "definition": "dist/index.d.ts"
26
+ },
24
27
  "author": {
25
28
  "name": "Kamil Kisiela",
26
29
  "email": "kamil.kisiela@gmail.com",
27
30
  "url": "https://github.com/kamilkisiela"
28
31
  },
29
32
  "license": "MIT",
30
- "main": "index.js",
31
- "module": "index.mjs",
32
- "typings": "index.d.ts",
33
- "typescript": {
34
- "definition": "index.d.ts"
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "kamilkisiela/graphql-inspector",
36
+ "directory": "packages/core"
35
37
  },
36
- "exports": {
37
- ".": {
38
- "require": "./index.js",
39
- "import": "./index.mjs"
40
- },
41
- "./*": {
42
- "require": "./*.js",
43
- "import": "./*.mjs"
44
- }
38
+ "peerDependencies": {
39
+ "graphql": "^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
40
+ },
41
+ "dependencies": {
42
+ "dependency-graph": "0.11.0",
43
+ "object-inspect": "1.10.3",
44
+ "tslib": "^2.0.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/object-inspect": "1.8.0"
48
+ },
49
+ "scripts": {
50
+ "prepack": "bob prepack"
45
51
  }
46
52
  }
@@ -0,0 +1,11 @@
1
+ // import { findDangerousChanges } from 'graphql';
2
+
3
+ import { Change } from '../src/diff/changes/change';
4
+
5
+ export function findChangesByPath(changes: Change[], path: string) {
6
+ return changes.filter((c) => c.path === path);
7
+ }
8
+
9
+ export function findFirstChangeByPath(changes: Change[], path: string) {
10
+ return findChangesByPath(changes, path)[0];
11
+ }