-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.d.ts
249 lines (213 loc) · 5.79 KB
/
index.d.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/* eslint-disable @typescript-eslint/no-explicit-any */
export const GraphQLInt: GraphQLInt;
export const GraphQLFloat: GraphQLFloat;
export const GraphQLString: GraphQLString;
export const GraphQLBoolean: GraphQLBoolean;
export const GraphQLID: GraphQLID;
export const Date: GraphQLDate;
export const DateTime: GraphQLDateTime;
export const Time: GraphQLTime;
export const Json: GraphQLJson;
export const LocalDateTime: GraphQLLocalDateTime;
export const LocalTime: GraphQLLocalTime;
/**
* Create an instance of SchemaGenerator
*/
export function newSchemaGenerator(): SchemaGenerator;
/**
* Returns a modified type that indicates a list of the underlying wrapped type
*/
export function list(type: GraphQLType): GraphQLListType;
/**
* Returns a modified type that indicates the underlying wrapped type will not be null
*/
export function nonNull(type: GraphQLType): GraphQLNonNullType;
/**
* Returns a special type that allows an object/interface type to reference a type by its key. Necessary for self reference.
*/
export function reference(typeKey: string): GraphQLTypeReference;
/**
* Executes a GraphQL query and variables against a schema
*/
export function execute<ExecuteContext = unknown, Result = any>(
schema: GraphQLSchema,
query: string,
variables: object,
context?: ExecuteContext,
): Result;
export type GraphQLSchema = unknown & { kind?: "SCHEMA" };
export type GraphQLInt = unknown & {
kind?: "SCALAR";
name: "Int";
};
export type GraphQLFloat = unknown & {
kind?: "SCALAR";
name: "Float";
};
export type GraphQLString = unknown & {
kind?: "SCALAR";
name: "String";
};
export type GraphQLBoolean = unknown & {
kind?: "SCALAR";
name: "Boolean";
};
export type GraphQLID = unknown & {
kind?: "SCALAR";
name: "ID";
};
export type GraphQLDate = unknown & {
kind?: "SCALAR";
name: "Date";
};
export type GraphQLDateTime = unknown & {
kind?: "SCALAR";
name: "DateTime";
};
export type GraphQLTime = unknown & {
kind?: "SCALAR";
name: "Time";
};
export type GraphQLJson = unknown & {
kind?: "SCALAR";
name: "JSON";
};
export type GraphQLLocalDateTime = unknown & {
kind?: "SCALAR";
name: "LocalDateTime";
};
export type GraphQLLocalTime = unknown & {
kind?: "SCALAR";
name: "LocalTime";
};
export type GraphQLScalarType =
| GraphQLInt
| GraphQLFloat
| GraphQLString
| GraphQLBoolean
| GraphQLID
| GraphQLDate
| GraphQLDateTime
| GraphQLTime
| GraphQLJson
| GraphQLLocalDateTime
| GraphQLLocalTime;
export type GraphQLObjectType = unknown & {
kind?: "OBJECT";
};
export type GraphQLInterfaceType = unknown & {
kind?: "INTERFACE";
};
export type GraphQLTypeReference = unknown & {
kind?: "reference";
};
export type GraphQLInputObjectType = unknown & {
kind?: "INPUT_OBJECT";
};
export type GraphQLInfoObjectType = unknown & {
kind?: "INFO_OBJECT";
};
export type GraphQLUnionType = unknown & {
kind?: "UNION";
};
export type GraphQLEnumType = unknown & {
kind?: "ENUM";
};
export type GraphQLNonNullType = unknown & {
kind?: "NON_NULL";
};
export type GraphQLListType = unknown & {
kind?: "LIST";
};
export type GraphQLType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLTypeReference
| GraphQLInputObjectType
| GraphQLInfoObjectType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLNonNullType
| GraphQLListType;
export interface SchemaGenerator {
/**
* Creates a GraphQL schema
*/
createSchema(params: CreateSchemaParams): GraphQLSchema;
/**
* Creates a GraphQL page info object type
*/
createPageInfoObjectType(params: CreatePageInfoObjectTypeParams): GraphQLInfoObjectType;
/**
* Creates a GraphQL object type
*/
createObjectType(params: CreateObjectTypeParams): GraphQLObjectType;
/**
* createInputObjectType
*/
createInputObjectType(params: CreateInputObjectTypeParams): GraphQLInputObjectType;
/**
* Creates a GraphQL interface type
*/
createInterfaceType(params: CreateInterfaceTypeParams): GraphQLInterfaceType;
/**
* Creates a GraphQL union type
*/
createUnionType(params: CreateUnionTypeParams): GraphQLUnionType;
/**
* Creates a GraphQL enum type
*/
createEnumType(params: CreateEnumTypeParams): GraphQLEnumType;
}
export interface CreateSchemaParams {
query: GraphQLObjectType;
mutation?: GraphQLObjectType;
subscription?: GraphQLObjectType;
dictionary: Array<GraphQLObjectType>;
}
export interface CreateEnumTypeParams {
readonly name: string;
readonly values: Array<string>;
readonly description?: string;
}
export interface GraphQLResolver {
type: GraphQLType;
args?: Record<string, GraphQLType>;
resolve?: <Environment extends GraphQLResolverEnvironment>(env: Environment) => unknown;
}
export interface GraphQLResolverEnvironment<Source = any, Context = any> {
source: Source;
args: Record<string, any>;
context: Context;
}
export interface CreateInterfaceTypeParams {
name: string;
fields: Record<string, GraphQLResolver>;
typeResolver: (env: any) => GraphQLObjectType;
description?: string;
}
export interface CreateUnionTypeParams {
name: string;
types: Array<GraphQLObjectType | GraphQLTypeReference>;
typeResolver: (env: any) => GraphQLObjectType;
}
export interface CreatePageInfoObjectTypeParams {
name: string;
fields: Record<string, GraphQLResolver>;
interfaces?: Array<GraphQLInterfaceType | GraphQLTypeReference>;
description?: string;
}
export interface CreateObjectTypeParams {
name: string;
description?: string;
fields: Record<string, GraphQLResolver>;
interfaces?: Array<GraphQLInterfaceType | GraphQLTypeReference>;
}
export interface CreateInputObjectTypeParams {
name: string;
description?: string;
fields: Record<string, GraphQLResolver>;
interfaces?: Array<GraphQLInterfaceType | GraphQLTypeReference>;
}
/* eslint-enable @typescript-eslint/no-explicit-any */