@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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/ast/document.d.ts +15 -0
  4. package/coverage/index.d.ts +38 -0
  5. package/coverage/output/json.d.ts +2 -0
  6. package/diff/argument.d.ts +3 -0
  7. package/diff/changes/argument.d.ts +5 -0
  8. package/diff/changes/change.d.ts +69 -0
  9. package/diff/changes/directive.d.ts +12 -0
  10. package/diff/changes/enum.d.ts +8 -0
  11. package/diff/changes/field.d.ts +15 -0
  12. package/diff/changes/input.d.ts +9 -0
  13. package/diff/changes/object.d.ts +4 -0
  14. package/diff/changes/schema.d.ts +5 -0
  15. package/diff/changes/type.d.ts +8 -0
  16. package/diff/changes/union.d.ts +4 -0
  17. package/diff/directive.d.ts +3 -0
  18. package/diff/enum.d.ts +3 -0
  19. package/diff/field.d.ts +3 -0
  20. package/diff/index.d.ts +9 -0
  21. package/diff/input.d.ts +3 -0
  22. package/diff/interface.d.ts +3 -0
  23. package/diff/object.d.ts +3 -0
  24. package/diff/onComplete/types.d.ts +7 -0
  25. package/diff/rules/config.d.ts +2 -0
  26. package/diff/rules/consider-usage.d.ts +29 -0
  27. package/diff/rules/dangerous-breaking.d.ts +2 -0
  28. package/diff/rules/ignore-description-changes.d.ts +2 -0
  29. package/diff/rules/index.d.ts +5 -0
  30. package/diff/rules/safe-unreachable.d.ts +2 -0
  31. package/diff/rules/suppress-removal-of-deprecated-field.d.ts +2 -0
  32. package/diff/rules/types.d.ts +8 -0
  33. package/diff/schema.d.ts +4 -0
  34. package/diff/union.d.ts +3 -0
  35. package/index.d.ts +7 -0
  36. package/index.js +1855 -0
  37. package/index.mjs +1846 -0
  38. package/package.json +46 -0
  39. package/similar/index.d.ts +6 -0
  40. package/utils/apollo.d.ts +5 -0
  41. package/utils/compare.d.ts +22 -0
  42. package/utils/graphql.d.ts +11 -0
  43. package/utils/isDeprecated.d.ts +2 -0
  44. package/utils/path.d.ts +1 -0
  45. package/utils/string.d.ts +14 -0
  46. package/validate/index.d.ts +34 -0
  47. 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>;
@@ -0,0 +1,2 @@
1
+ import { GraphQLInputField, GraphQLEnumValue, GraphQLField } from 'graphql';
2
+ export declare function isDeprecated(fieldOrEnumValue: GraphQLField<any, any> | GraphQLEnumValue | GraphQLInputField): boolean;
@@ -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;