@graphql-inspector/core 0.0.0-PLACEHOLDER
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/LICENSE +21 -0
- package/README.md +55 -0
- package/ast/document.d.ts +15 -0
- package/coverage/index.d.ts +38 -0
- package/coverage/output/json.d.ts +2 -0
- package/diff/argument.d.ts +3 -0
- package/diff/changes/argument.d.ts +5 -0
- package/diff/changes/change.d.ts +69 -0
- package/diff/changes/directive.d.ts +12 -0
- package/diff/changes/enum.d.ts +8 -0
- package/diff/changes/field.d.ts +15 -0
- package/diff/changes/input.d.ts +9 -0
- package/diff/changes/object.d.ts +4 -0
- package/diff/changes/schema.d.ts +5 -0
- package/diff/changes/type.d.ts +8 -0
- package/diff/changes/union.d.ts +4 -0
- package/diff/directive.d.ts +3 -0
- package/diff/enum.d.ts +3 -0
- package/diff/field.d.ts +3 -0
- package/diff/index.d.ts +9 -0
- package/diff/input.d.ts +3 -0
- package/diff/interface.d.ts +3 -0
- package/diff/object.d.ts +3 -0
- package/diff/onComplete/types.d.ts +7 -0
- package/diff/rules/config.d.ts +2 -0
- package/diff/rules/consider-usage.d.ts +29 -0
- package/diff/rules/dangerous-breaking.d.ts +2 -0
- package/diff/rules/ignore-description-changes.d.ts +2 -0
- package/diff/rules/index.d.ts +5 -0
- package/diff/rules/safe-unreachable.d.ts +2 -0
- package/diff/rules/suppress-removal-of-deprecated-field.d.ts +2 -0
- package/diff/rules/types.d.ts +8 -0
- package/diff/schema.d.ts +4 -0
- package/diff/union.d.ts +3 -0
- package/index.d.ts +7 -0
- package/index.js +1855 -0
- package/index.mjs +1846 -0
- package/package.json +46 -0
- package/similar/index.d.ts +6 -0
- package/utils/apollo.d.ts +5 -0
- package/utils/compare.d.ts +22 -0
- package/utils/graphql.d.ts +11 -0
- package/utils/isDeprecated.d.ts +2 -0
- package/utils/path.d.ts +1 -0
- package/utils/string.d.ts +14 -0
- package/validate/index.d.ts +34 -0
- package/validate/query-depth.d.ts +14 -0
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphql-inspector/core",
|
|
3
|
+
"version": "0.0.0-PLACEHOLDER",
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { BestMatch } from '../utils/string';
|
|
3
|
+
export interface SimilarMap {
|
|
4
|
+
[name: string]: BestMatch;
|
|
5
|
+
}
|
|
6
|
+
export declare function similar(schema: GraphQLSchema, typeName: string | undefined, threshold?: number): SimilarMap;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
2
|
+
export declare function transformDocumentWithApollo(doc: DocumentNode, { keepClientFields }: {
|
|
3
|
+
keepClientFields: boolean;
|
|
4
|
+
}): DocumentNode;
|
|
5
|
+
export declare function transformSchemaWithApollo(schema: GraphQLSchema): GraphQLSchema;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function keyMap<T>(list: readonly T[], keyFn: (item: T) => string): Record<string, T>;
|
|
2
|
+
export declare function isEqual<T>(a: T, b: T): boolean;
|
|
3
|
+
export declare function isNotEqual<T>(a: T, b: T): boolean;
|
|
4
|
+
export declare function isVoid<T>(a: T): boolean;
|
|
5
|
+
export declare function diffArrays<T>(a: T[] | readonly T[], b: T[] | readonly T[]): T[];
|
|
6
|
+
export declare function compareLists<T extends {
|
|
7
|
+
name: string;
|
|
8
|
+
}>(oldList: readonly T[], newList: readonly T[], callbacks?: {
|
|
9
|
+
onAdded?(t: T): void;
|
|
10
|
+
onRemoved?(t: T): void;
|
|
11
|
+
onMutual?(t: {
|
|
12
|
+
newVersion: T;
|
|
13
|
+
oldVersion: T;
|
|
14
|
+
}): void;
|
|
15
|
+
}): {
|
|
16
|
+
added: T[];
|
|
17
|
+
removed: T[];
|
|
18
|
+
mutual: {
|
|
19
|
+
newVersion: T;
|
|
20
|
+
oldVersion: T;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GraphQLInputType, GraphQLOutputType, GraphQLNamedType, KindEnum, GraphQLSchema, GraphQLError, DocumentNode, FieldNode } from 'graphql';
|
|
2
|
+
export declare function safeChangeForField(oldType: GraphQLOutputType, newType: GraphQLOutputType): boolean;
|
|
3
|
+
export declare function safeChangeForInputValue(oldType: GraphQLInputType, newType: GraphQLInputType): boolean;
|
|
4
|
+
export declare function getKind(type: GraphQLNamedType): KindEnum;
|
|
5
|
+
export declare function getTypePrefix(type: GraphQLNamedType): string;
|
|
6
|
+
export declare function isPrimitive(type: GraphQLNamedType | string): boolean;
|
|
7
|
+
export declare function isForIntrospection(type: GraphQLNamedType | string): boolean;
|
|
8
|
+
export declare function findDeprecatedUsages(schema: GraphQLSchema, ast: DocumentNode): Array<GraphQLError>;
|
|
9
|
+
export declare function removeFieldIfDirectives(node: FieldNode, directiveNames: string[]): FieldNode | null;
|
|
10
|
+
export declare function removeDirectives(node: FieldNode, directiveNames: string[]): FieldNode;
|
|
11
|
+
export declare function getReachableTypes(schema: GraphQLSchema): Set<string>;
|
package/utils/path.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parsePath(path: string): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Target {
|
|
2
|
+
typeId: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Rating {
|
|
6
|
+
target: Target;
|
|
7
|
+
rating: number;
|
|
8
|
+
}
|
|
9
|
+
export interface BestMatch {
|
|
10
|
+
ratings: Rating[];
|
|
11
|
+
bestMatch: Rating;
|
|
12
|
+
}
|
|
13
|
+
export declare function findBestMatch(mainString: string, targetStrings: Target[]): BestMatch;
|
|
14
|
+
export declare function safeString(obj: any): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { GraphQLSchema, GraphQLError, Source } from 'graphql';
|
|
2
|
+
export interface InvalidDocument {
|
|
3
|
+
source: Source;
|
|
4
|
+
errors: GraphQLError[];
|
|
5
|
+
deprecated: GraphQLError[];
|
|
6
|
+
}
|
|
7
|
+
export interface ValidateOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Fails on duplicated fragment names
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
strictFragments?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Fails on deprecated usage
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
strictDeprecated?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Works only with combination of `apollo`
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
keepClientFields?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Supports Apollo directives (`@client` and `@connection`)
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
apollo?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Fails when operation depth exceeds maximum depth
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
maxDepth?: number;
|
|
33
|
+
}
|
|
34
|
+
export declare function validate(schema: GraphQLSchema, sources: Source[], options?: ValidateOptions): InvalidDocument[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DepGraph } from 'dependency-graph';
|
|
2
|
+
import { DocumentNode, GraphQLError, ASTNode, FragmentDefinitionNode, Source } from 'graphql';
|
|
3
|
+
export declare function validateQueryDepth({ source, doc, maxDepth, fragmentGraph, }: {
|
|
4
|
+
source: Source;
|
|
5
|
+
doc: DocumentNode;
|
|
6
|
+
maxDepth: number;
|
|
7
|
+
fragmentGraph: DepGraph<FragmentDefinitionNode>;
|
|
8
|
+
}): GraphQLError | void;
|
|
9
|
+
export declare function calculateDepth({ node, currentDepth, maxDepth, getFragment, }: {
|
|
10
|
+
node: ASTNode;
|
|
11
|
+
currentDepth: number;
|
|
12
|
+
maxDepth?: number;
|
|
13
|
+
getFragment: (fragmentName: string) => FragmentDefinitionNode;
|
|
14
|
+
}): number | never;
|