@graphql-inspector/core 3.1.4 → 3.4.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.
- package/README.md +5 -3
- package/{dist/ast → ast}/document.d.ts +0 -0
- package/{dist/coverage → coverage}/index.d.ts +0 -0
- package/{dist/coverage → coverage}/output/json.d.ts +0 -0
- package/{dist/diff → diff}/argument.d.ts +0 -0
- package/{dist/diff → diff}/changes/argument.d.ts +0 -0
- package/{dist/diff → diff}/changes/change.d.ts +0 -0
- package/{dist/diff → diff}/changes/directive.d.ts +0 -0
- package/{dist/diff → diff}/changes/enum.d.ts +0 -0
- package/{dist/diff → diff}/changes/field.d.ts +0 -0
- package/{dist/diff → diff}/changes/input.d.ts +0 -0
- package/{dist/diff → diff}/changes/object.d.ts +0 -0
- package/{dist/diff → diff}/changes/schema.d.ts +0 -0
- package/{dist/diff → diff}/changes/type.d.ts +0 -0
- package/{dist/diff → diff}/changes/union.d.ts +0 -0
- package/{dist/diff → diff}/directive.d.ts +0 -0
- package/{dist/diff → diff}/enum.d.ts +0 -0
- package/{dist/diff → diff}/field.d.ts +0 -0
- package/{dist/diff → diff}/index.d.ts +0 -0
- package/{dist/diff → diff}/input.d.ts +0 -0
- package/{dist/diff → diff}/interface.d.ts +0 -0
- package/{dist/diff → diff}/object.d.ts +0 -0
- package/{dist/diff → diff}/onComplete/types.d.ts +0 -0
- package/{dist/diff → diff}/rules/config.d.ts +0 -0
- package/{dist/diff → diff}/rules/consider-usage.d.ts +0 -0
- package/{dist/diff → diff}/rules/dangerous-breaking.d.ts +0 -0
- package/{dist/diff → diff}/rules/ignore-description-changes.d.ts +0 -0
- package/{dist/diff → diff}/rules/index.d.ts +0 -0
- package/{dist/diff → diff}/rules/safe-unreachable.d.ts +0 -0
- package/{dist/diff → diff}/rules/suppress-removal-of-deprecated-field.d.ts +0 -0
- package/{dist/diff → diff}/rules/types.d.ts +0 -0
- package/{dist/diff → diff}/schema.d.ts +0 -0
- package/{dist/diff → diff}/union.d.ts +0 -0
- package/index.d.ts +12 -0
- package/{dist/index.js → index.js} +325 -157
- package/{dist/index.mjs → index.mjs} +322 -159
- package/package.json +29 -35
- package/{dist/similar → similar}/index.d.ts +0 -0
- package/{dist/utils → utils}/apollo.d.ts +0 -0
- package/{dist/utils → utils}/compare.d.ts +0 -0
- package/{dist/utils → utils}/graphql.d.ts +0 -0
- package/utils/isDeprecated.d.ts +2 -0
- package/{dist/utils → utils}/path.d.ts +0 -0
- package/{dist/utils → utils}/string.d.ts +0 -0
- package/validate/alias-count.d.ts +10 -0
- package/validate/complexity.d.ts +16 -0
- package/validate/directive-count.d.ts +10 -0
- package/{dist/validate → validate}/index.d.ts +17 -2
- package/{dist/validate → validate}/query-depth.d.ts +2 -1
- package/validate/token-count.d.ts +12 -0
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -55
- package/dist/index.d.ts +0 -7
- package/dist/package.json +0 -46
- package/dist/utils/isDeprecated.d.ts +0 -2
- package/utils/testing.ts +0 -11
package/package.json
CHANGED
|
@@ -1,52 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-inspector/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.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
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
"
|
|
50
|
-
"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import type { DocumentNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
|
+
import { GraphQLError } from 'graphql';
|
|
4
|
+
export declare function validateAliasCount({ source, doc, maxAliasCount, fragmentGraph, }: {
|
|
5
|
+
source: Source;
|
|
6
|
+
doc: DocumentNode;
|
|
7
|
+
maxAliasCount: number;
|
|
8
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
9
|
+
}): GraphQLError | void;
|
|
10
|
+
export declare function countAliases(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, getFragmentByName: (fragmentName: string) => FragmentDefinitionNode | undefined): number;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import type { DocumentNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
|
+
import { GraphQLError } from 'graphql';
|
|
4
|
+
export declare type CalculateOperationComplexityConfig = {
|
|
5
|
+
scalarCost: number;
|
|
6
|
+
objectCost: number;
|
|
7
|
+
depthCostFactor: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function validateComplexity({ source, doc, maxComplexityScore, config, fragmentGraph, }: {
|
|
10
|
+
source: Source;
|
|
11
|
+
doc: DocumentNode;
|
|
12
|
+
maxComplexityScore: number;
|
|
13
|
+
config: CalculateOperationComplexityConfig;
|
|
14
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
15
|
+
}): GraphQLError | void;
|
|
16
|
+
export declare function calculateOperationComplexity(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, config: CalculateOperationComplexityConfig, getFragmentByName: (fragmentName: string) => FragmentDefinitionNode | undefined, depth?: number): number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import type { DocumentNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
|
+
import { GraphQLError } from 'graphql';
|
|
4
|
+
export declare function validateDirectiveCount({ source, doc, maxDirectiveCount, fragmentGraph, }: {
|
|
5
|
+
source: Source;
|
|
6
|
+
doc: DocumentNode;
|
|
7
|
+
maxDirectiveCount: number;
|
|
8
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
9
|
+
}): GraphQLError | void;
|
|
10
|
+
export declare function countDirectives(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, getFragmentByName: (fragmentName: string) => FragmentDefinitionNode | undefined): number;
|
|
@@ -26,9 +26,24 @@ export interface ValidateOptions {
|
|
|
26
26
|
*/
|
|
27
27
|
apollo?: boolean;
|
|
28
28
|
/**
|
|
29
|
-
* Fails when operation depth exceeds maximum depth
|
|
30
|
-
* @default
|
|
29
|
+
* Fails when operation depth exceeds maximum depth (including the referenced fragments).
|
|
30
|
+
* @default Infinity
|
|
31
31
|
*/
|
|
32
32
|
maxDepth?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Fails when alias count exceeds maximum count (including the referenced fragments).
|
|
35
|
+
* @default Infinity
|
|
36
|
+
*/
|
|
37
|
+
maxAliasCount?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Fails when the directive count exceeds maximum count for a single operation (including the referenced fragments).
|
|
40
|
+
* @default Infinity
|
|
41
|
+
*/
|
|
42
|
+
maxDirectiveCount?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Fails when the token count exceeds maximum count for a single operation (including the referenced fragments).
|
|
45
|
+
* @default Infinity
|
|
46
|
+
*/
|
|
47
|
+
maxTokenCount?: number;
|
|
33
48
|
}
|
|
34
49
|
export declare function validate(schema: GraphQLSchema, sources: Source[], options?: ValidateOptions): InvalidDocument[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DepGraph } from 'dependency-graph';
|
|
2
|
-
import { DocumentNode, GraphQLError, ASTNode, FragmentDefinitionNode, Source } from 'graphql';
|
|
2
|
+
import { DocumentNode, GraphQLError, ASTNode, FragmentDefinitionNode, Source, FieldNode, InlineFragmentNode, OperationDefinitionNode, FragmentSpreadNode } from 'graphql';
|
|
3
3
|
export declare function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }: {
|
|
4
4
|
source: Source;
|
|
5
5
|
doc: DocumentNode;
|
|
@@ -12,3 +12,4 @@ export declare function calculateDepth({ node, currentDepth, maxDepth, getFragme
|
|
|
12
12
|
maxDepth?: number;
|
|
13
13
|
getFragment: (fragmentName: string) => FragmentDefinitionNode;
|
|
14
14
|
}): number | never;
|
|
15
|
+
export declare function countDepth(node: FieldNode | FragmentDefinitionNode | InlineFragmentNode | OperationDefinitionNode | FragmentSpreadNode, parentDepth: number, getFragmentReference: (name: string) => FragmentDefinitionNode | undefined): number;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DocumentNode, GraphQLError } from 'graphql';
|
|
2
|
+
import type { Source } from 'graphql';
|
|
3
|
+
export declare function calculateTokenCount(args: {
|
|
4
|
+
source: Source | string;
|
|
5
|
+
getReferencedFragmentSource: (fragmentName: string) => Source | string | undefined;
|
|
6
|
+
}): number;
|
|
7
|
+
export declare function validateTokenCount(args: {
|
|
8
|
+
source: Source;
|
|
9
|
+
document: DocumentNode;
|
|
10
|
+
getReferencedFragmentSource: (fragmentName: string) => Source | string | undefined;
|
|
11
|
+
maxTokenCount: number;
|
|
12
|
+
}): GraphQLError | void;
|
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
|
-
[](https://circleci.com/gh/kamilkisiela/graphql-inspector)
|
|
4
|
-
[](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/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { diff, DiffRule, Rule, CompletionArgs, CompletionHandler, UsageHandler, } from './diff';
|
|
2
|
-
export { validate, InvalidDocument } from './validate';
|
|
3
|
-
export { similar, SimilarMap } from './similar';
|
|
4
|
-
export * from './coverage';
|
|
5
|
-
export { Change, CriticalityLevel, Criticality, ChangeType, } from './diff/changes/change';
|
|
6
|
-
export { getTypePrefix } from './utils/graphql';
|
|
7
|
-
export { Target, Rating, BestMatch } from './utils/string';
|
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
|
-
}
|
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
|
-
}
|