/
types.ts
136 lines (114 loc) · 3.97 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { GraphQLEnumType, GraphQLInputObjectType, GraphQLNamedType, GraphQLScalarType, visit } from 'graphql';
export interface SchemaPrintOptions {
/**
* Descriptions are defined as preceding string literals, however an older
* experimental version of the SDL supported preceding comments as
* descriptions. Set to true to enable this deprecated behavior.
* This option is provided to ease adoption and will be removed in v16.
*
* Default: false
*/
commentDescriptions?: boolean;
assumeValid?: boolean;
}
export interface GetDocumentNodeFromSchemaOptions {
pathToDirectivesInExtensions?: Array<string>;
}
export type PrintSchemaWithDirectivesOptions = SchemaPrintOptions & GetDocumentNodeFromSchemaOptions;
export type Maybe<T> = null | undefined | T;
export type Constructor<T> = new (...args: any[]) => T;
export type PruneSchemaFilter = (type: GraphQLNamedType) => boolean;
/**
* Options for removing unused types from the schema
*/
export interface PruneSchemaOptions {
/**
* Return true to skip pruning this type. This check will run first before any other options.
* This can be helpful for schemas that support type extensions like Apollo Federation.
*/
skipPruning?: PruneSchemaFilter;
/**
* Set to `true` to skip pruning object types or interfaces with no no fields
*/
skipEmptyCompositeTypePruning?: boolean;
/**
* Set to `true` to skip pruning interfaces that are not implemented by any
* other types
*/
skipUnimplementedInterfacesPruning?: boolean;
/**
* Set to `true` to skip pruning empty unions
*/
skipEmptyUnionPruning?: boolean;
/**
* Set to `true` to skip pruning unused types
*/
skipUnusedTypesPruning?: boolean;
}
export type InputLeafValueTransformer = (type: GraphQLEnumType | GraphQLScalarType, originalValue: any) => any;
export type InputObjectValueTransformer = (
type: GraphQLInputObjectType,
originalValue: Record<string, any>
) => Record<string, any>;
// GraphQL v14 doesn't have it. Remove this once we drop support for v14
export type ASTVisitorKeyMap = Partial<Parameters<typeof visit>[2]>;
export type DirectiveLocationEnum = typeof DirectiveLocation;
export enum DirectiveLocation {
/** Request Definitions */
QUERY = 'QUERY',
MUTATION = 'MUTATION',
SUBSCRIPTION = 'SUBSCRIPTION',
FIELD = 'FIELD',
FRAGMENT_DEFINITION = 'FRAGMENT_DEFINITION',
FRAGMENT_SPREAD = 'FRAGMENT_SPREAD',
INLINE_FRAGMENT = 'INLINE_FRAGMENT',
VARIABLE_DEFINITION = 'VARIABLE_DEFINITION',
/** Type System Definitions */
SCHEMA = 'SCHEMA',
SCALAR = 'SCALAR',
OBJECT = 'OBJECT',
FIELD_DEFINITION = 'FIELD_DEFINITION',
ARGUMENT_DEFINITION = 'ARGUMENT_DEFINITION',
INTERFACE = 'INTERFACE',
UNION = 'UNION',
ENUM = 'ENUM',
ENUM_VALUE = 'ENUM_VALUE',
INPUT_OBJECT = 'INPUT_OBJECT',
INPUT_FIELD_DEFINITION = 'INPUT_FIELD_DEFINITION',
}
export type ExtensionsObject = Record<string, any>;
export type ObjectTypeExtensions = {
type: 'object';
fields: Record<string, { extensions: ExtensionsObject; arguments: Record<string, ExtensionsObject> }>;
};
export type InputTypeExtensions = {
type: 'input';
fields: Record<string, { extensions: ExtensionsObject }>;
};
export type InterfaceTypeExtensions = {
type: 'interface';
fields: Record<string, { extensions: ExtensionsObject; arguments: Record<string, ExtensionsObject> }>;
};
export type UnionTypeExtensions = {
type: 'union';
};
export type ScalarTypeExtensions = {
type: 'scalar';
};
export type EnumTypeExtensions = {
type: 'enum';
values: Record<string, ExtensionsObject>;
};
export type PossibleTypeExtensions =
| InputTypeExtensions
| InterfaceTypeExtensions
| ObjectTypeExtensions
| UnionTypeExtensions
| ScalarTypeExtensions
| EnumTypeExtensions;
export type SchemaExtensions = {
schemaExtensions: ExtensionsObject;
types: Record<string, { extensions: ExtensionsObject } & PossibleTypeExtensions>;
};
export type DirectiveArgs = { [name: string]: any };
export type DirectiveUsage = { name: string; args: DirectiveArgs };