@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/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/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
@@ -0,0 +1,15 @@
1
+ import { OperationDefinitionNode, FragmentDefinitionNode, Source } from 'graphql';
2
+ export interface Document {
3
+ source: Source;
4
+ fragments: {
5
+ node: FragmentDefinitionNode;
6
+ source: string;
7
+ }[];
8
+ operations: {
9
+ node: OperationDefinitionNode;
10
+ source: string;
11
+ }[];
12
+ hasFragments: boolean;
13
+ hasOperations: boolean;
14
+ }
15
+ export declare function readDocument(source: Source): Document;
@@ -0,0 +1,38 @@
1
+ import { GraphQLSchema, GraphQLError, Source, GraphQLNamedType } from 'graphql';
2
+ export interface Location {
3
+ start: number;
4
+ end: number;
5
+ }
6
+ export interface ArgumentCoverage {
7
+ hits: number;
8
+ locations: {
9
+ [name: string]: Array<Location>;
10
+ };
11
+ }
12
+ export interface TypeChildCoverage {
13
+ hits: number;
14
+ locations: {
15
+ [name: string]: Array<Location>;
16
+ };
17
+ children: {
18
+ [name: string]: ArgumentCoverage;
19
+ };
20
+ }
21
+ export interface TypeCoverage {
22
+ hits: number;
23
+ type: GraphQLNamedType;
24
+ children: {
25
+ [name: string]: TypeChildCoverage;
26
+ };
27
+ }
28
+ export interface SchemaCoverage {
29
+ sources: Source[];
30
+ types: {
31
+ [typename: string]: TypeCoverage;
32
+ };
33
+ }
34
+ export interface InvalidDocument {
35
+ source: Source;
36
+ errors: ReadonlyArray<GraphQLError>;
37
+ }
38
+ export declare function coverage(schema: GraphQLSchema, sources: Source[]): SchemaCoverage;
@@ -0,0 +1,2 @@
1
+ import { SchemaCoverage } from '../index';
2
+ export declare function outputJSON(coverage: SchemaCoverage): string;
@@ -0,0 +1,3 @@
1
+ import { GraphQLArgument, GraphQLObjectType, GraphQLField, GraphQLInterfaceType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInArgument(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>, oldArg: GraphQLArgument, newArg: GraphQLArgument, addChange: AddChange): void;
@@ -0,0 +1,5 @@
1
+ import { GraphQLArgument, GraphQLObjectType, GraphQLField, GraphQLInterfaceType } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function fieldArgumentDescriptionChanged(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>, oldArg: GraphQLArgument, newArg: GraphQLArgument): Change;
4
+ export declare function fieldArgumentDefaultChanged(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>, oldArg: GraphQLArgument, newArg: GraphQLArgument): Change;
5
+ export declare function fieldArgumentTypeChanged(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>, oldArg: GraphQLArgument, newArg: GraphQLArgument): Change;
@@ -0,0 +1,69 @@
1
+ export declare enum ChangeType {
2
+ FieldArgumentDescriptionChanged = "FIELD_ARGUMENT_DESCRIPTION_CHANGED",
3
+ FieldArgumentDefaultChanged = "FIELD_ARGUMENT_DEFAULT_CHANGED",
4
+ FieldArgumentTypeChanged = "FIELD_ARGUMENT_TYPE_CHANGED",
5
+ DirectiveRemoved = "DIRECTIVE_REMOVED",
6
+ DirectiveAdded = "DIRECTIVE_ADDED",
7
+ DirectiveDescriptionChanged = "DIRECTIVE_DESCRIPTION_CHANGED",
8
+ DirectiveLocationAdded = "DIRECTIVE_LOCATION_ADDED",
9
+ DirectiveLocationRemoved = "DIRECTIVE_LOCATION_REMOVED",
10
+ DirectiveArgumentAdded = "DIRECTIVE_ARGUMENT_ADDED",
11
+ DirectiveArgumentRemoved = "DIRECTIVE_ARGUMENT_REMOVED",
12
+ DirectiveArgumentDescriptionChanged = "DIRECTIVE_ARGUMENT_DESCRIPTION_CHANGED",
13
+ DirectiveArgumentDefaultValueChanged = "DIRECTIVE_ARGUMENT_DEFAULT_VALUE_CHANGED",
14
+ DirectiveArgumentTypeChanged = "DIRECTIVE_ARGUMENT_TYPE_CHANGED",
15
+ EnumValueRemoved = "ENUM_VALUE_REMOVED",
16
+ EnumValueAdded = "ENUM_VALUE_ADDED",
17
+ EnumValueDescriptionChanged = "ENUM_VALUE_DESCRIPTION_CHANGED",
18
+ EnumValueDeprecationReasonChanged = "ENUM_VALUE_DEPRECATION_REASON_CHANGED",
19
+ EnumValueDeprecationReasonAdded = "ENUM_VALUE_DEPRECATION_REASON_ADDED",
20
+ EnumValueDeprecationReasonRemoved = "ENUM_VALUE_DEPRECATION_REASON_REMOVED",
21
+ FieldRemoved = "FIELD_REMOVED",
22
+ FieldAdded = "FIELD_ADDED",
23
+ FieldDescriptionChanged = "FIELD_DESCRIPTION_CHANGED",
24
+ FieldDescriptionAdded = "FIELD_DESCRIPTION_ADDED",
25
+ FieldDescriptionRemoved = "FIELD_DESCRIPTION_REMOVED",
26
+ FieldDeprecationAdded = "FIELD_DEPRECATION_ADDED",
27
+ FieldDeprecationRemoved = "FIELD_DEPRECATION_REMOVED",
28
+ FieldDeprecationReasonChanged = "FIELD_DEPRECATION_REASON_CHANGED",
29
+ FieldDeprecationReasonAdded = "FIELD_DEPRECATION_REASON_ADDED",
30
+ FieldDeprecationReasonRemoved = "FIELD_DEPRECATION_REASON_REMOVED",
31
+ FieldTypeChanged = "FIELD_TYPE_CHANGED",
32
+ FieldArgumentAdded = "FIELD_ARGUMENT_ADDED",
33
+ FieldArgumentRemoved = "FIELD_ARGUMENT_REMOVED",
34
+ InputFieldRemoved = "INPUT_FIELD_REMOVED",
35
+ InputFieldAdded = "INPUT_FIELD_ADDED",
36
+ InputFieldDescriptionAdded = "INPUT_FIELD_DESCRIPTION_ADDED",
37
+ InputFieldDescriptionRemoved = "INPUT_FIELD_DESCRIPTION_REMOVED",
38
+ InputFieldDescriptionChanged = "INPUT_FIELD_DESCRIPTION_CHANGED",
39
+ InputFieldDefaultValueChanged = "INPUT_FIELD_DEFAULT_VALUE_CHANGED",
40
+ InputFieldTypeChanged = "INPUT_FIELD_TYPE_CHANGED",
41
+ ObjectTypeInterfaceAdded = "OBJECT_TYPE_INTERFACE_ADDED",
42
+ ObjectTypeInterfaceRemoved = "OBJECT_TYPE_INTERFACE_REMOVED",
43
+ SchemaQueryTypeChanged = "SCHEMA_QUERY_TYPE_CHANGED",
44
+ SchemaMutationTypeChanged = "SCHEMA_MUTATION_TYPE_CHANGED",
45
+ SchemaSubscriptionTypeChanged = "SCHEMA_SUBSCRIPTION_TYPE_CHANGED",
46
+ TypeRemoved = "TYPE_REMOVED",
47
+ TypeAdded = "TYPE_ADDED",
48
+ TypeKindChanged = "TYPE_KIND_CHANGED",
49
+ TypeDescriptionChanged = "TYPE_DESCRIPTION_CHANGED",
50
+ TypeDescriptionRemoved = "TYPE_DESCRIPTION_REMOVED",
51
+ TypeDescriptionAdded = "TYPE_DESCRIPTION_ADDED",
52
+ UnionMemberRemoved = "UNION_MEMBER_REMOVED",
53
+ UnionMemberAdded = "UNION_MEMBER_ADDED"
54
+ }
55
+ export declare enum CriticalityLevel {
56
+ Breaking = "BREAKING",
57
+ NonBreaking = "NON_BREAKING",
58
+ Dangerous = "DANGEROUS"
59
+ }
60
+ export interface Criticality {
61
+ level: CriticalityLevel;
62
+ reason?: string;
63
+ }
64
+ export interface Change {
65
+ message: string;
66
+ path?: string;
67
+ type: ChangeType;
68
+ criticality: Criticality;
69
+ }
@@ -0,0 +1,12 @@
1
+ import { GraphQLDirective, DirectiveLocationEnum, GraphQLArgument } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function directiveRemoved(directive: GraphQLDirective): Change;
4
+ export declare function directiveAdded(directive: GraphQLDirective): Change;
5
+ export declare function directiveDescriptionChanged(oldDirective: GraphQLDirective, newDirective: GraphQLDirective): Change;
6
+ export declare function directiveLocationAdded(directive: GraphQLDirective, location: DirectiveLocationEnum): Change;
7
+ export declare function directiveLocationRemoved(directive: GraphQLDirective, location: DirectiveLocationEnum): Change;
8
+ export declare function directiveArgumentAdded(directive: GraphQLDirective, arg: GraphQLArgument): Change;
9
+ export declare function directiveArgumentRemoved(directive: GraphQLDirective, arg: GraphQLArgument): Change;
10
+ export declare function directiveArgumentDescriptionChanged(directive: GraphQLDirective, oldArg: GraphQLArgument, newArg: GraphQLArgument): Change;
11
+ export declare function directiveArgumentDefaultValueChanged(directive: GraphQLDirective, oldArg: GraphQLArgument, newArg: GraphQLArgument): Change;
12
+ export declare function directiveArgumentTypeChanged(directive: GraphQLDirective, oldArg: GraphQLArgument, newArg: GraphQLArgument): Change;
@@ -0,0 +1,8 @@
1
+ import { GraphQLEnumType, GraphQLEnumValue } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function enumValueRemoved(oldEnum: GraphQLEnumType, value: GraphQLEnumValue): Change;
4
+ export declare function enumValueAdded(newEnum: GraphQLEnumType, value: GraphQLEnumValue): Change;
5
+ export declare function enumValueDescriptionChanged(newEnum: GraphQLEnumType, oldValue: GraphQLEnumValue, newValue: GraphQLEnumValue): Change;
6
+ export declare function enumValueDeprecationReasonChanged(newEnum: GraphQLEnumType, oldValue: GraphQLEnumValue, newValue: GraphQLEnumValue): Change;
7
+ export declare function enumValueDeprecationReasonAdded(newEnum: GraphQLEnumType, oldValue: GraphQLEnumValue, newValue: GraphQLEnumValue): Change;
8
+ export declare function enumValueDeprecationReasonRemoved(newEnum: GraphQLEnumType, oldValue: GraphQLEnumValue, newValue: GraphQLEnumValue): Change;
@@ -0,0 +1,15 @@
1
+ import { GraphQLObjectType, GraphQLField, GraphQLArgument, GraphQLInterfaceType } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function fieldRemoved(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>): Change;
4
+ export declare function fieldAdded(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>): Change;
5
+ export declare function fieldDescriptionChanged(type: GraphQLObjectType | GraphQLInterfaceType, oldField: GraphQLField<any, any>, newField: GraphQLField<any, any>): Change;
6
+ export declare function fieldDescriptionAdded(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any>): Change;
7
+ export declare function fieldDescriptionRemoved(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any>): Change;
8
+ export declare function fieldDeprecationAdded(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any>): Change;
9
+ export declare function fieldDeprecationRemoved(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any>): Change;
10
+ export declare function fieldDeprecationReasonChanged(type: GraphQLObjectType | GraphQLInterfaceType, oldField: GraphQLField<any, any>, newField: GraphQLField<any, any>): Change;
11
+ export declare function fieldDeprecationReasonAdded(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any>): Change;
12
+ export declare function fieldDeprecationReasonRemoved(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any>): Change;
13
+ export declare function fieldTypeChanged(type: GraphQLObjectType | GraphQLInterfaceType, oldField: GraphQLField<any, any, any>, newField: GraphQLField<any, any, any>): Change;
14
+ export declare function fieldArgumentAdded(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>, arg: GraphQLArgument): Change;
15
+ export declare function fieldArgumentRemoved(type: GraphQLObjectType | GraphQLInterfaceType, field: GraphQLField<any, any, any>, arg: GraphQLArgument): Change;
@@ -0,0 +1,9 @@
1
+ import { GraphQLInputObjectType, GraphQLInputField } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function inputFieldRemoved(input: GraphQLInputObjectType, field: GraphQLInputField): Change;
4
+ export declare function inputFieldAdded(input: GraphQLInputObjectType, field: GraphQLInputField): Change;
5
+ export declare function inputFieldDescriptionAdded(type: GraphQLInputObjectType, field: GraphQLInputField): Change;
6
+ export declare function inputFieldDescriptionRemoved(type: GraphQLInputObjectType, field: GraphQLInputField): Change;
7
+ export declare function inputFieldDescriptionChanged(input: GraphQLInputObjectType, oldField: GraphQLInputField, newField: GraphQLInputField): Change;
8
+ export declare function inputFieldDefaultValueChanged(input: GraphQLInputObjectType, oldField: GraphQLInputField, newField: GraphQLInputField): Change;
9
+ export declare function inputFieldTypeChanged(input: GraphQLInputObjectType, oldField: GraphQLInputField, newField: GraphQLInputField): Change;
@@ -0,0 +1,4 @@
1
+ import { GraphQLInterfaceType, GraphQLObjectType } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function objectTypeInterfaceAdded(iface: GraphQLInterfaceType, type: GraphQLObjectType): Change;
4
+ export declare function objectTypeInterfaceRemoved(iface: GraphQLInterfaceType, type: GraphQLObjectType): Change;
@@ -0,0 +1,5 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function schemaQueryTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change;
4
+ export declare function schemaMutationTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change;
5
+ export declare function schemaSubscriptionTypeChanged(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change;
@@ -0,0 +1,8 @@
1
+ import { GraphQLNamedType } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function typeRemoved(type: GraphQLNamedType): Change;
4
+ export declare function typeAdded(type: GraphQLNamedType): Change;
5
+ export declare function typeKindChanged(oldType: GraphQLNamedType, newType: GraphQLNamedType): Change;
6
+ export declare function typeDescriptionChanged(oldType: GraphQLNamedType, newType: GraphQLNamedType): Change;
7
+ export declare function typeDescriptionRemoved(type: GraphQLNamedType): Change;
8
+ export declare function typeDescriptionAdded(type: GraphQLNamedType): Change;
@@ -0,0 +1,4 @@
1
+ import { GraphQLUnionType, GraphQLObjectType } from 'graphql';
2
+ import { Change } from './change';
3
+ export declare function unionMemberRemoved(union: GraphQLUnionType, type: GraphQLObjectType): Change;
4
+ export declare function unionMemberAdded(union: GraphQLUnionType, type: GraphQLObjectType): Change;
@@ -0,0 +1,3 @@
1
+ import { GraphQLDirective } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInDirective(oldDirective: GraphQLDirective, newDirective: GraphQLDirective, addChange: AddChange): void;
package/diff/enum.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { GraphQLEnumType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInEnum(oldEnum: GraphQLEnumType, newEnum: GraphQLEnumType, addChange: AddChange): void;
@@ -0,0 +1,3 @@
1
+ import { GraphQLField, GraphQLObjectType, GraphQLInterfaceType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInField(type: GraphQLObjectType | GraphQLInterfaceType, oldField: GraphQLField<any, any>, newField: GraphQLField<any, any>, addChange: AddChange): void;
@@ -0,0 +1,9 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Change } from './changes/change';
3
+ import { Rule } from './rules/types';
4
+ import * as rules from './rules';
5
+ export * from './rules/types';
6
+ export declare const DiffRule: typeof rules;
7
+ export * from './onComplete/types';
8
+ export type { UsageHandler } from './rules/consider-usage';
9
+ export declare function diff(oldSchema: GraphQLSchema, newSchema: GraphQLSchema, rules?: Rule[], config?: rules.ConsiderUsageConfig): Promise<Change[]>;
@@ -0,0 +1,3 @@
1
+ import { GraphQLInputObjectType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInInputObject(oldInput: GraphQLInputObjectType, newInput: GraphQLInputObjectType, addChange: AddChange): void;
@@ -0,0 +1,3 @@
1
+ import { GraphQLInterfaceType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInInterface(oldInterface: GraphQLInterfaceType, newInterface: GraphQLInterfaceType, addChange: AddChange): void;
@@ -0,0 +1,3 @@
1
+ import { GraphQLObjectType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInObject(oldType: GraphQLObjectType, newType: GraphQLObjectType, addChange: AddChange): void;
@@ -0,0 +1,7 @@
1
+ import { Change } from '../changes/change';
2
+ export declare type CompletionArgs = {
3
+ breakingChanges: Change[];
4
+ dangerousChanges: Change[];
5
+ nonBreakingChanges: Change[];
6
+ };
7
+ export declare type CompletionHandler = (args: CompletionArgs) => void;
@@ -0,0 +1,2 @@
1
+ import { ConsiderUsageConfig } from './consider-usage';
2
+ export declare type Config = ConsiderUsageConfig;
@@ -0,0 +1,29 @@
1
+ import { Rule } from './types';
2
+ export declare type UsageHandler = (input: Array<{
3
+ type: string;
4
+ field?: string;
5
+ argument?: string;
6
+ }>) => Promise<boolean[]>;
7
+ export interface ConsiderUsageConfig {
8
+ /**
9
+ * Checks if it's safe to introduce a breaking change on a field
10
+ *
11
+ * Because the function is async and resolves to a boolean value
12
+ * you can add pretty much anything here, many different conditions or
13
+ * even any source of data.
14
+ *
15
+ * In the CLI we use a GraphQL endpoint with a query
16
+ * that checks the usage and returns stats like:
17
+ * min/max count and min/max precentage
18
+ * So we know when to allow for a breaking change.
19
+ *
20
+ * Because it returns a boolean,
21
+ * we can't attach any data or even customize a message of an api change.
22
+ * This is the first iteration, we're going to improve it soon.
23
+ *
24
+ * true - NON_BREAKING
25
+ * false - BREAKING
26
+ */
27
+ checkUsage?: UsageHandler;
28
+ }
29
+ export declare const considerUsage: Rule<ConsiderUsageConfig>;
@@ -0,0 +1,2 @@
1
+ import { Rule } from './types';
2
+ export declare const dangerousBreaking: Rule;
@@ -0,0 +1,2 @@
1
+ import { Rule } from './types';
2
+ export declare const ignoreDescriptionChanges: Rule;
@@ -0,0 +1,5 @@
1
+ export * from './dangerous-breaking';
2
+ export * from './suppress-removal-of-deprecated-field';
3
+ export * from './ignore-description-changes';
4
+ export * from './consider-usage';
5
+ export * from './safe-unreachable';
@@ -0,0 +1,2 @@
1
+ import { Rule } from './types';
2
+ export declare const safeUnreachable: Rule;
@@ -0,0 +1,2 @@
1
+ import { Rule } from './types';
2
+ export declare const suppressRemovalOfDeprecatedField: Rule;
@@ -0,0 +1,8 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Change } from '../changes/change';
3
+ export declare type Rule<TConfig = any> = (input: {
4
+ changes: Change[];
5
+ oldSchema: GraphQLSchema;
6
+ newSchema: GraphQLSchema;
7
+ config: TConfig;
8
+ }) => Change[] | Promise<Change[]>;
@@ -0,0 +1,4 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Change } from './changes/change';
3
+ export declare type AddChange = (change: Change) => void;
4
+ export declare function diffSchema(oldSchema: GraphQLSchema, newSchema: GraphQLSchema): Change[];
@@ -0,0 +1,3 @@
1
+ import { GraphQLUnionType } from 'graphql';
2
+ import { AddChange } from './schema';
3
+ export declare function changesInUnion(oldUnion: GraphQLUnionType, newUnion: GraphQLUnionType, addChange: AddChange): void;
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
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';