@graphql-inspector/core 3.1.4 → 3.2.0

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/{dist/ast → ast}/document.d.ts +0 -0
  2. package/{dist/coverage → coverage}/index.d.ts +0 -0
  3. package/{dist/coverage → coverage}/output/json.d.ts +0 -0
  4. package/{dist/diff → diff}/argument.d.ts +0 -0
  5. package/{dist/diff → diff}/changes/argument.d.ts +0 -0
  6. package/{dist/diff → diff}/changes/change.d.ts +0 -0
  7. package/{dist/diff → diff}/changes/directive.d.ts +0 -0
  8. package/{dist/diff → diff}/changes/enum.d.ts +0 -0
  9. package/{dist/diff → diff}/changes/field.d.ts +0 -0
  10. package/{dist/diff → diff}/changes/input.d.ts +0 -0
  11. package/{dist/diff → diff}/changes/object.d.ts +0 -0
  12. package/{dist/diff → diff}/changes/schema.d.ts +0 -0
  13. package/{dist/diff → diff}/changes/type.d.ts +0 -0
  14. package/{dist/diff → diff}/changes/union.d.ts +0 -0
  15. package/{dist/diff → diff}/directive.d.ts +0 -0
  16. package/{dist/diff → diff}/enum.d.ts +0 -0
  17. package/{dist/diff → diff}/field.d.ts +0 -0
  18. package/{dist/diff → diff}/index.d.ts +0 -0
  19. package/{dist/diff → diff}/input.d.ts +0 -0
  20. package/{dist/diff → diff}/interface.d.ts +0 -0
  21. package/{dist/diff → diff}/object.d.ts +0 -0
  22. package/{dist/diff → diff}/onComplete/types.d.ts +0 -0
  23. package/{dist/diff → diff}/rules/config.d.ts +0 -0
  24. package/{dist/diff → diff}/rules/consider-usage.d.ts +0 -0
  25. package/{dist/diff → diff}/rules/dangerous-breaking.d.ts +0 -0
  26. package/{dist/diff → diff}/rules/ignore-description-changes.d.ts +0 -0
  27. package/{dist/diff → diff}/rules/index.d.ts +0 -0
  28. package/{dist/diff → diff}/rules/safe-unreachable.d.ts +0 -0
  29. package/{dist/diff → diff}/rules/suppress-removal-of-deprecated-field.d.ts +0 -0
  30. package/{dist/diff → diff}/rules/types.d.ts +0 -0
  31. package/{dist/diff → diff}/schema.d.ts +0 -0
  32. package/{dist/diff → diff}/union.d.ts +0 -0
  33. package/{dist/index.d.ts → index.d.ts} +0 -0
  34. package/{dist/index.js → index.js} +14 -2
  35. package/{dist/index.mjs → index.mjs} +14 -2
  36. package/package.json +29 -35
  37. package/{dist/similar → similar}/index.d.ts +0 -0
  38. package/{dist/utils → utils}/apollo.d.ts +0 -0
  39. package/{dist/utils → utils}/compare.d.ts +0 -0
  40. package/{dist/utils → utils}/graphql.d.ts +0 -0
  41. package/utils/isDeprecated.d.ts +2 -0
  42. package/{dist/utils → utils}/path.d.ts +0 -0
  43. package/{dist/utils → utils}/string.d.ts +0 -0
  44. package/{dist/validate → validate}/index.d.ts +0 -0
  45. package/{dist/validate → validate}/query-depth.d.ts +0 -0
  46. package/dist/LICENSE +0 -21
  47. package/dist/README.md +0 -55
  48. package/dist/package.json +0 -46
  49. package/dist/utils/isDeprecated.d.ts +0 -2
  50. package/utils/testing.ts +0 -11
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -129,7 +129,7 @@ function safeChangeForInputValue(oldType, newType) {
129
129
  return safeChangeForInputValue(oldType.ofType, newType.ofType);
130
130
  }
131
131
  if (graphql.isNonNullType(oldType)) {
132
- const ofType = graphql.isNonNullType(newType) ? newType : newType;
132
+ const ofType = graphql.isNonNullType(newType) ? newType.ofType : newType;
133
133
  return safeChangeForInputValue(oldType.ofType, ofType);
134
134
  }
135
135
  return false;
@@ -703,7 +703,7 @@ function inputFieldRemoved(input, field) {
703
703
  reason: 'Removing an input field will cause existing queries that use this input field to error.',
704
704
  },
705
705
  type: exports.ChangeType.InputFieldRemoved,
706
- message: `Input field '${field.name}' was removed from input object type '${input.name}'`,
706
+ message: `Input field '${field.name}' ${isDeprecated(field) ? '(deprecated) ' : ''}was removed from input object type '${input.name}'`,
707
707
  path: [input.name, field.name].join('.'),
708
708
  };
709
709
  }
@@ -1370,6 +1370,18 @@ const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, }) => {
1370
1370
  }
1371
1371
  }
1372
1372
  }
1373
+ if (change.type === exports.ChangeType.InputFieldRemoved &&
1374
+ change.criticality.level === exports.CriticalityLevel.Breaking &&
1375
+ change.path) {
1376
+ const [inputName, inputItem] = parsePath(change.path);
1377
+ const type = oldSchema.getType(inputName);
1378
+ if (graphql.isInputObjectType(type)) {
1379
+ const item = type.getFields()[inputItem];
1380
+ if (item && isDeprecated(item)) {
1381
+ return Object.assign(Object.assign({}, change), { criticality: Object.assign(Object.assign({}, change.criticality), { level: exports.CriticalityLevel.Dangerous }) });
1382
+ }
1383
+ }
1384
+ }
1373
1385
  return change;
1374
1386
  });
1375
1387
  };
@@ -123,7 +123,7 @@ function safeChangeForInputValue(oldType, newType) {
123
123
  return safeChangeForInputValue(oldType.ofType, newType.ofType);
124
124
  }
125
125
  if (isNonNullType(oldType)) {
126
- const ofType = isNonNullType(newType) ? newType : newType;
126
+ const ofType = isNonNullType(newType) ? newType.ofType : newType;
127
127
  return safeChangeForInputValue(oldType.ofType, ofType);
128
128
  }
129
129
  return false;
@@ -699,7 +699,7 @@ function inputFieldRemoved(input, field) {
699
699
  reason: 'Removing an input field will cause existing queries that use this input field to error.',
700
700
  },
701
701
  type: ChangeType.InputFieldRemoved,
702
- message: `Input field '${field.name}' was removed from input object type '${input.name}'`,
702
+ message: `Input field '${field.name}' ${isDeprecated(field) ? '(deprecated) ' : ''}was removed from input object type '${input.name}'`,
703
703
  path: [input.name, field.name].join('.'),
704
704
  };
705
705
  }
@@ -1366,6 +1366,18 @@ const suppressRemovalOfDeprecatedField = ({ changes, oldSchema, }) => {
1366
1366
  }
1367
1367
  }
1368
1368
  }
1369
+ if (change.type === ChangeType.InputFieldRemoved &&
1370
+ change.criticality.level === CriticalityLevel.Breaking &&
1371
+ change.path) {
1372
+ const [inputName, inputItem] = parsePath(change.path);
1373
+ const type = oldSchema.getType(inputName);
1374
+ if (isInputObjectType(type)) {
1375
+ const item = type.getFields()[inputItem];
1376
+ if (item && isDeprecated(item)) {
1377
+ return Object.assign(Object.assign({}, change), { criticality: Object.assign(Object.assign({}, change.criticality), { level: CriticalityLevel.Dangerous }) });
1378
+ }
1379
+ }
1380
+ }
1369
1381
  return change;
1370
1382
  });
1371
1383
  };
package/package.json CHANGED
@@ -1,52 +1,46 @@
1
1
  {
2
2
  "name": "@graphql-inspector/core",
3
- "version": "3.1.4",
3
+ "version": "3.2.0",
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
+ },
5
19
  "keywords": [
6
20
  "graphql",
7
21
  "graphql-inspector",
8
22
  "tools"
9
23
  ],
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
- },
27
24
  "author": {
28
25
  "name": "Kamil Kisiela",
29
26
  "email": "kamil.kisiela@gmail.com",
30
27
  "url": "https://github.com/kamilkisiela"
31
28
  },
32
29
  "license": "MIT",
33
- "repository": {
34
- "type": "git",
35
- "url": "kamilkisiela/graphql-inspector",
36
- "directory": "packages/core"
37
- },
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"
30
+ "main": "index.js",
31
+ "module": "index.mjs",
32
+ "typings": "index.d.ts",
33
+ "typescript": {
34
+ "definition": "index.d.ts"
48
35
  },
49
- "scripts": {
50
- "prepack": "bob prepack"
36
+ "exports": {
37
+ ".": {
38
+ "require": "./index.js",
39
+ "import": "./index.mjs"
40
+ },
41
+ "./*": {
42
+ "require": "./*.js",
43
+ "import": "./*.mjs"
44
+ }
51
45
  }
52
46
  }
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ import { GraphQLInputField, GraphQLEnumValue, GraphQLField } from 'graphql';
2
+ export declare function isDeprecated(fieldOrEnumValue: GraphQLField<any, any> | GraphQLEnumValue | GraphQLInputField): boolean;
File without changes
File without changes
File without changes
File without changes
package/dist/LICENSE DELETED
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,55 +0,0 @@
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
package/dist/package.json DELETED
@@ -1,46 +0,0 @@
1
- {
2
- "name": "@graphql-inspector/core",
3
- "version": "3.1.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
- "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
- }
@@ -1,2 +0,0 @@
1
- import { GraphQLEnumValue, GraphQLField } from 'graphql';
2
- export declare function isDeprecated(fieldOrEnumValue: GraphQLField<any, any> | GraphQLEnumValue): boolean;
package/utils/testing.ts DELETED
@@ -1,11 +0,0 @@
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
- }