@power-plant/graphql-codegen 0.0.2
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 +201 -0
- package/README.md +265 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +4677 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4677 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +88 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4677 @@
|
|
|
1
|
+
import { Types } from "@graphql-codegen/plugin-helpers";
|
|
2
|
+
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/jsutils/Maybe.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Conveniently represents flow's "Maybe" type https://flow.org/en/docs/types/maybe/
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
type Maybe<T> = null | undefined | T;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/jsutils/ObjMap.d.ts
|
|
14
|
+
/** @internal */
|
|
15
|
+
interface ObjMap<T> {
|
|
16
|
+
[key: string]: T;
|
|
17
|
+
}
|
|
18
|
+
/** @internal */
|
|
19
|
+
interface ReadOnlyObjMap<T> {
|
|
20
|
+
readonly [key: string]: T;
|
|
21
|
+
}
|
|
22
|
+
declare namespace kinds__d_exports {
|
|
23
|
+
export { ARGUMENT, ARGUMENT_COORDINATE, BOOLEAN, DIRECTIVE, DIRECTIVE_ARGUMENT_COORDINATE, DIRECTIVE_COORDINATE, DIRECTIVE_DEFINITION, DIRECTIVE_EXTENSION, DOCUMENT, ENUM, ENUM_TYPE_DEFINITION, ENUM_TYPE_EXTENSION, ENUM_VALUE_DEFINITION, FIELD, FIELD_DEFINITION, FLOAT, FRAGMENT_ARGUMENT, FRAGMENT_DEFINITION, FRAGMENT_SPREAD, INLINE_FRAGMENT, INPUT_OBJECT_TYPE_DEFINITION, INPUT_OBJECT_TYPE_EXTENSION, INPUT_VALUE_DEFINITION, INT, INTERFACE_TYPE_DEFINITION, INTERFACE_TYPE_EXTENSION, LIST, LIST_TYPE, MEMBER_COORDINATE, NAME, NAMED_TYPE, NON_NULL_TYPE, NULL, OBJECT, OBJECT_FIELD, OBJECT_TYPE_DEFINITION, OBJECT_TYPE_EXTENSION, OPERATION_DEFINITION, OPERATION_TYPE_DEFINITION, SCALAR_TYPE_DEFINITION, SCALAR_TYPE_EXTENSION, SCHEMA_DEFINITION, SCHEMA_EXTENSION, SELECTION_SET, STRING, TYPE_COORDINATE, UNION_TYPE_DEFINITION, UNION_TYPE_EXTENSION, VARIABLE, VARIABLE_DEFINITION };
|
|
24
|
+
}
|
|
25
|
+
/** @category Kinds */
|
|
26
|
+
/** AST kind for name nodes. */
|
|
27
|
+
declare const NAME = "Name";
|
|
28
|
+
/** Type of the `Kind.NAME` AST kind value. */
|
|
29
|
+
type NAME = typeof NAME;
|
|
30
|
+
/** AST kind for document nodes. */
|
|
31
|
+
declare const DOCUMENT = "Document";
|
|
32
|
+
/** Type of the `Kind.DOCUMENT` AST kind value. */
|
|
33
|
+
type DOCUMENT = typeof DOCUMENT;
|
|
34
|
+
/** AST kind for operation definition nodes. */
|
|
35
|
+
declare const OPERATION_DEFINITION = "OperationDefinition";
|
|
36
|
+
/** Type of the `Kind.OPERATION_DEFINITION` AST kind value. */
|
|
37
|
+
type OPERATION_DEFINITION = typeof OPERATION_DEFINITION;
|
|
38
|
+
/** AST kind for variable definition nodes. */
|
|
39
|
+
declare const VARIABLE_DEFINITION = "VariableDefinition";
|
|
40
|
+
/** Type of the `Kind.VARIABLE_DEFINITION` AST kind value. */
|
|
41
|
+
type VARIABLE_DEFINITION = typeof VARIABLE_DEFINITION;
|
|
42
|
+
/** AST kind for selection set nodes. */
|
|
43
|
+
declare const SELECTION_SET = "SelectionSet";
|
|
44
|
+
/** Type of the `Kind.SELECTION_SET` AST kind value. */
|
|
45
|
+
type SELECTION_SET = typeof SELECTION_SET;
|
|
46
|
+
/** AST kind for field selection nodes. */
|
|
47
|
+
declare const FIELD = "Field";
|
|
48
|
+
/** Type of the `Kind.FIELD` AST kind value. */
|
|
49
|
+
type FIELD = typeof FIELD;
|
|
50
|
+
/** AST kind for argument nodes. */
|
|
51
|
+
declare const ARGUMENT = "Argument";
|
|
52
|
+
/** Type of the `Kind.ARGUMENT` AST kind value. */
|
|
53
|
+
type ARGUMENT = typeof ARGUMENT;
|
|
54
|
+
/** AST kind for fragment argument nodes. */
|
|
55
|
+
declare const FRAGMENT_ARGUMENT = "FragmentArgument";
|
|
56
|
+
/** Type of the `Kind.FRAGMENT_ARGUMENT` AST kind value. */
|
|
57
|
+
type FRAGMENT_ARGUMENT = typeof FRAGMENT_ARGUMENT;
|
|
58
|
+
/** AST kind for fragment spread nodes. */
|
|
59
|
+
declare const FRAGMENT_SPREAD = "FragmentSpread";
|
|
60
|
+
/** Type of the `Kind.FRAGMENT_SPREAD` AST kind value. */
|
|
61
|
+
type FRAGMENT_SPREAD = typeof FRAGMENT_SPREAD;
|
|
62
|
+
/** AST kind for inline fragment nodes. */
|
|
63
|
+
declare const INLINE_FRAGMENT = "InlineFragment";
|
|
64
|
+
/** Type of the `Kind.INLINE_FRAGMENT` AST kind value. */
|
|
65
|
+
type INLINE_FRAGMENT = typeof INLINE_FRAGMENT;
|
|
66
|
+
/** AST kind for fragment definition nodes. */
|
|
67
|
+
declare const FRAGMENT_DEFINITION = "FragmentDefinition";
|
|
68
|
+
/** Type of the `Kind.FRAGMENT_DEFINITION` AST kind value. */
|
|
69
|
+
type FRAGMENT_DEFINITION = typeof FRAGMENT_DEFINITION;
|
|
70
|
+
/** AST kind for variable reference nodes. */
|
|
71
|
+
declare const VARIABLE = "Variable";
|
|
72
|
+
/** Type of the `Kind.VARIABLE` AST kind value. */
|
|
73
|
+
type VARIABLE = typeof VARIABLE;
|
|
74
|
+
/** AST kind for integer value nodes. */
|
|
75
|
+
declare const INT = "IntValue";
|
|
76
|
+
/** Type of the `Kind.INT` AST kind value. */
|
|
77
|
+
type INT = typeof INT;
|
|
78
|
+
/** AST kind for floating-point value nodes. */
|
|
79
|
+
declare const FLOAT = "FloatValue";
|
|
80
|
+
/** Type of the `Kind.FLOAT` AST kind value. */
|
|
81
|
+
type FLOAT = typeof FLOAT;
|
|
82
|
+
/** AST kind for string value nodes. */
|
|
83
|
+
declare const STRING = "StringValue";
|
|
84
|
+
/** Type of the `Kind.STRING` AST kind value. */
|
|
85
|
+
type STRING = typeof STRING;
|
|
86
|
+
/** AST kind for boolean value nodes. */
|
|
87
|
+
declare const BOOLEAN = "BooleanValue";
|
|
88
|
+
/** Type of the `Kind.BOOLEAN` AST kind value. */
|
|
89
|
+
type BOOLEAN = typeof BOOLEAN;
|
|
90
|
+
/** AST kind for null value nodes. */
|
|
91
|
+
declare const NULL = "NullValue";
|
|
92
|
+
/** Type of the `Kind.NULL` AST kind value. */
|
|
93
|
+
type NULL = typeof NULL;
|
|
94
|
+
/** AST kind for enum value nodes. */
|
|
95
|
+
declare const ENUM = "EnumValue";
|
|
96
|
+
/** Type of the `Kind.ENUM` AST kind value. */
|
|
97
|
+
type ENUM = typeof ENUM;
|
|
98
|
+
/** AST kind for list value nodes. */
|
|
99
|
+
declare const LIST = "ListValue";
|
|
100
|
+
/** Type of the `Kind.LIST` AST kind value. */
|
|
101
|
+
type LIST = typeof LIST;
|
|
102
|
+
/** AST kind for object value nodes. */
|
|
103
|
+
declare const OBJECT = "ObjectValue";
|
|
104
|
+
/** Type of the `Kind.OBJECT` AST kind value. */
|
|
105
|
+
type OBJECT = typeof OBJECT;
|
|
106
|
+
/** AST kind for object field nodes. */
|
|
107
|
+
declare const OBJECT_FIELD = "ObjectField";
|
|
108
|
+
/** Type of the `Kind.OBJECT_FIELD` AST kind value. */
|
|
109
|
+
type OBJECT_FIELD = typeof OBJECT_FIELD;
|
|
110
|
+
/** AST kind for directive nodes. */
|
|
111
|
+
declare const DIRECTIVE = "Directive";
|
|
112
|
+
/** Type of the `Kind.DIRECTIVE` AST kind value. */
|
|
113
|
+
type DIRECTIVE = typeof DIRECTIVE;
|
|
114
|
+
/** AST kind for named type reference nodes. */
|
|
115
|
+
declare const NAMED_TYPE = "NamedType";
|
|
116
|
+
/** Type of the `Kind.NAMED_TYPE` AST kind value. */
|
|
117
|
+
type NAMED_TYPE = typeof NAMED_TYPE;
|
|
118
|
+
/** AST kind for list type reference nodes. */
|
|
119
|
+
declare const LIST_TYPE = "ListType";
|
|
120
|
+
/** Type of the `Kind.LIST_TYPE` AST kind value. */
|
|
121
|
+
type LIST_TYPE = typeof LIST_TYPE;
|
|
122
|
+
/** AST kind for non-null type reference nodes. */
|
|
123
|
+
declare const NON_NULL_TYPE = "NonNullType";
|
|
124
|
+
/** Type of the `Kind.NON_NULL_TYPE` AST kind value. */
|
|
125
|
+
type NON_NULL_TYPE = typeof NON_NULL_TYPE;
|
|
126
|
+
/** AST kind for schema definition nodes. */
|
|
127
|
+
declare const SCHEMA_DEFINITION = "SchemaDefinition";
|
|
128
|
+
/** Type of the `Kind.SCHEMA_DEFINITION` AST kind value. */
|
|
129
|
+
type SCHEMA_DEFINITION = typeof SCHEMA_DEFINITION;
|
|
130
|
+
/** AST kind for operation type definition nodes. */
|
|
131
|
+
declare const OPERATION_TYPE_DEFINITION = "OperationTypeDefinition";
|
|
132
|
+
/** Type of the `Kind.OPERATION_TYPE_DEFINITION` AST kind value. */
|
|
133
|
+
type OPERATION_TYPE_DEFINITION = typeof OPERATION_TYPE_DEFINITION;
|
|
134
|
+
/** AST kind for scalar type definition nodes. */
|
|
135
|
+
declare const SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition";
|
|
136
|
+
/** Type of the `Kind.SCALAR_TYPE_DEFINITION` AST kind value. */
|
|
137
|
+
type SCALAR_TYPE_DEFINITION = typeof SCALAR_TYPE_DEFINITION;
|
|
138
|
+
/** AST kind for object type definition nodes. */
|
|
139
|
+
declare const OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition";
|
|
140
|
+
/** Type of the `Kind.OBJECT_TYPE_DEFINITION` AST kind value. */
|
|
141
|
+
type OBJECT_TYPE_DEFINITION = typeof OBJECT_TYPE_DEFINITION;
|
|
142
|
+
/** AST kind for field definition nodes. */
|
|
143
|
+
declare const FIELD_DEFINITION = "FieldDefinition";
|
|
144
|
+
/** Type of the `Kind.FIELD_DEFINITION` AST kind value. */
|
|
145
|
+
type FIELD_DEFINITION = typeof FIELD_DEFINITION;
|
|
146
|
+
/** AST kind for input value definition nodes. */
|
|
147
|
+
declare const INPUT_VALUE_DEFINITION = "InputValueDefinition";
|
|
148
|
+
/** Type of the `Kind.INPUT_VALUE_DEFINITION` AST kind value. */
|
|
149
|
+
type INPUT_VALUE_DEFINITION = typeof INPUT_VALUE_DEFINITION;
|
|
150
|
+
/** AST kind for interface type definition nodes. */
|
|
151
|
+
declare const INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition";
|
|
152
|
+
/** Type of the `Kind.INTERFACE_TYPE_DEFINITION` AST kind value. */
|
|
153
|
+
type INTERFACE_TYPE_DEFINITION = typeof INTERFACE_TYPE_DEFINITION;
|
|
154
|
+
/** AST kind for union type definition nodes. */
|
|
155
|
+
declare const UNION_TYPE_DEFINITION = "UnionTypeDefinition";
|
|
156
|
+
/** Type of the `Kind.UNION_TYPE_DEFINITION` AST kind value. */
|
|
157
|
+
type UNION_TYPE_DEFINITION = typeof UNION_TYPE_DEFINITION;
|
|
158
|
+
/** AST kind for enum type definition nodes. */
|
|
159
|
+
declare const ENUM_TYPE_DEFINITION = "EnumTypeDefinition";
|
|
160
|
+
/** AST kind for enum value definition nodes. */
|
|
161
|
+
declare const ENUM_VALUE_DEFINITION = "EnumValueDefinition";
|
|
162
|
+
/** Type of the `Kind.ENUM_VALUE_DEFINITION` AST kind value. */
|
|
163
|
+
type ENUM_VALUE_DEFINITION = typeof ENUM_VALUE_DEFINITION;
|
|
164
|
+
/** AST kind for input object type definition nodes. */
|
|
165
|
+
declare const INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition";
|
|
166
|
+
/** Type of the `Kind.INPUT_OBJECT_TYPE_DEFINITION` AST kind value. */
|
|
167
|
+
type INPUT_OBJECT_TYPE_DEFINITION = typeof INPUT_OBJECT_TYPE_DEFINITION;
|
|
168
|
+
/** AST kind for directive definition nodes. */
|
|
169
|
+
declare const DIRECTIVE_DEFINITION = "DirectiveDefinition";
|
|
170
|
+
/** Type of the `Kind.DIRECTIVE_DEFINITION` AST kind value. */
|
|
171
|
+
type DIRECTIVE_DEFINITION = typeof DIRECTIVE_DEFINITION;
|
|
172
|
+
/** AST kind for schema extension nodes. */
|
|
173
|
+
declare const SCHEMA_EXTENSION = "SchemaExtension";
|
|
174
|
+
/** Type of the `Kind.SCHEMA_EXTENSION` AST kind value. */
|
|
175
|
+
type SCHEMA_EXTENSION = typeof SCHEMA_EXTENSION;
|
|
176
|
+
/** AST kind for directive extension nodes. */
|
|
177
|
+
declare const DIRECTIVE_EXTENSION = "DirectiveExtension";
|
|
178
|
+
/** Type of the `Kind.DIRECTIVE_EXTENSION` AST kind value. */
|
|
179
|
+
type DIRECTIVE_EXTENSION = typeof DIRECTIVE_EXTENSION;
|
|
180
|
+
/** AST kind for scalar type extension nodes. */
|
|
181
|
+
declare const SCALAR_TYPE_EXTENSION = "ScalarTypeExtension";
|
|
182
|
+
/** Type of the `Kind.SCALAR_TYPE_EXTENSION` AST kind value. */
|
|
183
|
+
type SCALAR_TYPE_EXTENSION = typeof SCALAR_TYPE_EXTENSION;
|
|
184
|
+
/** AST kind for object type extension nodes. */
|
|
185
|
+
declare const OBJECT_TYPE_EXTENSION = "ObjectTypeExtension";
|
|
186
|
+
/** Type of the `Kind.OBJECT_TYPE_EXTENSION` AST kind value. */
|
|
187
|
+
type OBJECT_TYPE_EXTENSION = typeof OBJECT_TYPE_EXTENSION;
|
|
188
|
+
/** AST kind for interface type extension nodes. */
|
|
189
|
+
declare const INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension";
|
|
190
|
+
/** Type of the `Kind.INTERFACE_TYPE_EXTENSION` AST kind value. */
|
|
191
|
+
type INTERFACE_TYPE_EXTENSION = typeof INTERFACE_TYPE_EXTENSION;
|
|
192
|
+
/** AST kind for union type extension nodes. */
|
|
193
|
+
declare const UNION_TYPE_EXTENSION = "UnionTypeExtension";
|
|
194
|
+
/** Type of the `Kind.UNION_TYPE_EXTENSION` AST kind value. */
|
|
195
|
+
type UNION_TYPE_EXTENSION = typeof UNION_TYPE_EXTENSION;
|
|
196
|
+
/** AST kind for enum type extension nodes. */
|
|
197
|
+
declare const ENUM_TYPE_EXTENSION = "EnumTypeExtension";
|
|
198
|
+
/** Type of the `Kind.ENUM_TYPE_EXTENSION` AST kind value. */
|
|
199
|
+
type ENUM_TYPE_EXTENSION = typeof ENUM_TYPE_EXTENSION;
|
|
200
|
+
/** AST kind for input object type extension nodes. */
|
|
201
|
+
declare const INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
|
|
202
|
+
/** Type of the `Kind.INPUT_OBJECT_TYPE_EXTENSION` AST kind value. */
|
|
203
|
+
type INPUT_OBJECT_TYPE_EXTENSION = typeof INPUT_OBJECT_TYPE_EXTENSION;
|
|
204
|
+
/** AST kind for type coordinate nodes. */
|
|
205
|
+
declare const TYPE_COORDINATE = "TypeCoordinate";
|
|
206
|
+
/** Type of the `Kind.TYPE_COORDINATE` AST kind value. */
|
|
207
|
+
type TYPE_COORDINATE = typeof TYPE_COORDINATE;
|
|
208
|
+
/** AST kind for member coordinate nodes. */
|
|
209
|
+
declare const MEMBER_COORDINATE = "MemberCoordinate";
|
|
210
|
+
/** Type of the `Kind.MEMBER_COORDINATE` AST kind value. */
|
|
211
|
+
type MEMBER_COORDINATE = typeof MEMBER_COORDINATE;
|
|
212
|
+
/** AST kind for argument coordinate nodes. */
|
|
213
|
+
declare const ARGUMENT_COORDINATE = "ArgumentCoordinate";
|
|
214
|
+
/** Type of the `Kind.ARGUMENT_COORDINATE` AST kind value. */
|
|
215
|
+
type ARGUMENT_COORDINATE = typeof ARGUMENT_COORDINATE;
|
|
216
|
+
/** AST kind for directive coordinate nodes. */
|
|
217
|
+
declare const DIRECTIVE_COORDINATE = "DirectiveCoordinate";
|
|
218
|
+
/** Type of the `Kind.DIRECTIVE_COORDINATE` AST kind value. */
|
|
219
|
+
type DIRECTIVE_COORDINATE = typeof DIRECTIVE_COORDINATE;
|
|
220
|
+
/** AST kind for directive argument coordinate nodes. */
|
|
221
|
+
declare const DIRECTIVE_ARGUMENT_COORDINATE = "DirectiveArgumentCoordinate";
|
|
222
|
+
/** Type of the `Kind.DIRECTIVE_ARGUMENT_COORDINATE` AST kind value. */
|
|
223
|
+
type DIRECTIVE_ARGUMENT_COORDINATE = typeof DIRECTIVE_ARGUMENT_COORDINATE;
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/language/KindTypeMap.d.ts
|
|
226
|
+
/** @internal */
|
|
227
|
+
type KindTypeMap = typeof kinds__d_exports;
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/language/source.d.ts
|
|
230
|
+
/** @category Source */
|
|
231
|
+
interface Location$1 {
|
|
232
|
+
line: number;
|
|
233
|
+
column: number;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
|
|
237
|
+
* optional, but they are useful for clients who store GraphQL documents in source files.
|
|
238
|
+
* For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might
|
|
239
|
+
* be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`.
|
|
240
|
+
* The `line` and `column` properties in `locationOffset` are 1-indexed.
|
|
241
|
+
*/
|
|
242
|
+
declare class Source {
|
|
243
|
+
/** The GraphQL source text. */
|
|
244
|
+
body: string;
|
|
245
|
+
/** Name used in diagnostics for this source, such as a file path or request name. */
|
|
246
|
+
name: string;
|
|
247
|
+
/** One-indexed line and column where this source begins. */
|
|
248
|
+
locationOffset: Location$1;
|
|
249
|
+
/**
|
|
250
|
+
* Creates a Source instance.
|
|
251
|
+
* @param body - The GraphQL source text.
|
|
252
|
+
* @param name - Name used in diagnostics for this source.
|
|
253
|
+
* @param locationOffset - One-indexed line and column where this source begins.
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import { Source } from 'graphql/language';
|
|
257
|
+
*
|
|
258
|
+
* const source = new Source('type Query { greeting: String }', 'schema.graphql', {
|
|
259
|
+
* line: 10,
|
|
260
|
+
* column: 1,
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* source.body; // => 'type Query { greeting: String }'
|
|
264
|
+
* source.name; // => 'schema.graphql'
|
|
265
|
+
* source.locationOffset; // => { line: 10, column: 1 }
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
constructor(body: string, name?: string, locationOffset?: Location$1);
|
|
269
|
+
/**
|
|
270
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
271
|
+
* @returns The built-in string tag for this object.
|
|
272
|
+
*/
|
|
273
|
+
get [Symbol.toStringTag](): string;
|
|
274
|
+
}
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/language/tokenKind.d.ts
|
|
277
|
+
/** @category Lexing */
|
|
278
|
+
/**
|
|
279
|
+
* An exported enum describing the different kinds of tokens that the
|
|
280
|
+
* lexer emits.
|
|
281
|
+
*/
|
|
282
|
+
declare const TokenKind: {
|
|
283
|
+
readonly SOF: "<SOF>";
|
|
284
|
+
readonly EOF: "<EOF>";
|
|
285
|
+
readonly BANG: "!";
|
|
286
|
+
readonly DOLLAR: "$";
|
|
287
|
+
readonly AMP: "&";
|
|
288
|
+
readonly PAREN_L: "(";
|
|
289
|
+
readonly PAREN_R: ")";
|
|
290
|
+
readonly DOT: ".";
|
|
291
|
+
readonly SPREAD: "...";
|
|
292
|
+
readonly COLON: ":";
|
|
293
|
+
readonly EQUALS: "=";
|
|
294
|
+
readonly AT: "@";
|
|
295
|
+
readonly BRACKET_L: "[";
|
|
296
|
+
readonly BRACKET_R: "]";
|
|
297
|
+
readonly BRACE_L: "{";
|
|
298
|
+
readonly PIPE: "|";
|
|
299
|
+
readonly BRACE_R: "}";
|
|
300
|
+
readonly NAME: "Name";
|
|
301
|
+
readonly INT: "Int";
|
|
302
|
+
readonly FLOAT: "Float";
|
|
303
|
+
readonly STRING: "String";
|
|
304
|
+
readonly BLOCK_STRING: "BlockString";
|
|
305
|
+
readonly COMMENT: "Comment";
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* An exported enum describing the different kinds of tokens that the
|
|
309
|
+
* lexer emits.
|
|
310
|
+
*/
|
|
311
|
+
type TokenKind = (typeof TokenKind)[keyof typeof TokenKind];
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/language/ast.d.ts
|
|
314
|
+
/**
|
|
315
|
+
* Contains a range of UTF-8 character offsets and token references that
|
|
316
|
+
* identify the region of the source from which the AST derived.
|
|
317
|
+
*/
|
|
318
|
+
declare class Location {
|
|
319
|
+
/** The character offset at which this Node begins. */
|
|
320
|
+
readonly start: number;
|
|
321
|
+
/** The character offset at which this Node ends. */
|
|
322
|
+
readonly end: number;
|
|
323
|
+
/** The Token at which this Node begins. */
|
|
324
|
+
readonly startToken: Token;
|
|
325
|
+
/** The Token at which this Node ends. */
|
|
326
|
+
readonly endToken: Token;
|
|
327
|
+
/** The Source document the AST represents. */
|
|
328
|
+
readonly source: Source;
|
|
329
|
+
/**
|
|
330
|
+
* Creates a Location instance.
|
|
331
|
+
* @param startToken - The start token.
|
|
332
|
+
* @param endToken - The end token.
|
|
333
|
+
* @param source - Source document used to derive error locations.
|
|
334
|
+
* @example
|
|
335
|
+
* ```ts
|
|
336
|
+
* import { Location, Source, Token, TokenKind } from 'graphql/language';
|
|
337
|
+
*
|
|
338
|
+
* const source = new Source('{ hello }');
|
|
339
|
+
* const startToken = new Token(TokenKind.BRACE_L, 0, 1, 1, 1);
|
|
340
|
+
* const endToken = new Token(TokenKind.BRACE_R, 8, 9, 1, 9);
|
|
341
|
+
* const location = new Location(startToken, endToken, source);
|
|
342
|
+
*
|
|
343
|
+
* location.start; // => 0
|
|
344
|
+
* location.end; // => 9
|
|
345
|
+
* location.source.body; // => '{ hello }'
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
348
|
+
constructor(startToken: Token, endToken: Token, source: Source);
|
|
349
|
+
/**
|
|
350
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
351
|
+
* @returns The built-in string tag for this object.
|
|
352
|
+
*/
|
|
353
|
+
get [Symbol.toStringTag](): string;
|
|
354
|
+
/**
|
|
355
|
+
* Returns a JSON representation of this location.
|
|
356
|
+
* @returns The JSON-serializable representation.
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* import { parse } from 'graphql/language';
|
|
360
|
+
*
|
|
361
|
+
* const document = parse('{ hello }');
|
|
362
|
+
* const location = document.loc?.toJSON();
|
|
363
|
+
*
|
|
364
|
+
* location; // => { start: 0, end: 9 }
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
toJSON(): {
|
|
368
|
+
start: number;
|
|
369
|
+
end: number;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Represents a range of characters represented by a lexical token
|
|
374
|
+
* within a Source.
|
|
375
|
+
*/
|
|
376
|
+
declare class Token {
|
|
377
|
+
/** The kind of Token. */
|
|
378
|
+
readonly kind: TokenKind;
|
|
379
|
+
/** The character offset at which this Node begins. */
|
|
380
|
+
readonly start: number;
|
|
381
|
+
/** The character offset at which this Node ends. */
|
|
382
|
+
readonly end: number;
|
|
383
|
+
/** The 1-indexed line number on which this Token appears. */
|
|
384
|
+
readonly line: number;
|
|
385
|
+
/** The 1-indexed column number at which this Token begins. */
|
|
386
|
+
readonly column: number;
|
|
387
|
+
/**
|
|
388
|
+
* For non-punctuation tokens, represents the interpreted value of the token.
|
|
389
|
+
*
|
|
390
|
+
* Note: is undefined for punctuation tokens, but typed as string for
|
|
391
|
+
* convenience in the parser.
|
|
392
|
+
*/
|
|
393
|
+
readonly value: string;
|
|
394
|
+
/**
|
|
395
|
+
* Tokens exist as nodes in a double-linked-list amongst all tokens
|
|
396
|
+
* including ignored tokens. <SOF> is always the first node and <EOF>
|
|
397
|
+
* the last.
|
|
398
|
+
*/
|
|
399
|
+
readonly prev: Token | null;
|
|
400
|
+
/** Next token in the token stream, including ignored tokens. */
|
|
401
|
+
readonly next: Token | null;
|
|
402
|
+
/**
|
|
403
|
+
* Creates a Token instance.
|
|
404
|
+
* @param kind - Token kind produced by lexical analysis.
|
|
405
|
+
* @param start - Character offset where this token begins.
|
|
406
|
+
* @param end - Character offset where this token ends.
|
|
407
|
+
* @param line - One-indexed line number where this token begins.
|
|
408
|
+
* @param column - One-indexed column number where this token begins.
|
|
409
|
+
* @param value - Interpreted value for non-punctuation tokens.
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* import { Token, TokenKind } from 'graphql/language';
|
|
413
|
+
*
|
|
414
|
+
* const token = new Token(TokenKind.NAME, 2, 7, 1, 3, 'hello');
|
|
415
|
+
*
|
|
416
|
+
* token.kind; // => TokenKind.NAME
|
|
417
|
+
* token.value; // => 'hello'
|
|
418
|
+
* token.toJSON(); // => { kind: 'Name', value: 'hello', line: 1, column: 3 }
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
constructor(kind: TokenKind, start: number, end: number, line: number, column: number, value?: string);
|
|
422
|
+
/**
|
|
423
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
424
|
+
* @returns The built-in string tag for this object.
|
|
425
|
+
*/
|
|
426
|
+
get [Symbol.toStringTag](): string;
|
|
427
|
+
/**
|
|
428
|
+
* Returns a JSON representation of this token.
|
|
429
|
+
* @returns The JSON-serializable representation.
|
|
430
|
+
* @example
|
|
431
|
+
* ```ts
|
|
432
|
+
* import { Lexer, Source } from 'graphql/language';
|
|
433
|
+
*
|
|
434
|
+
* const lexer = new Lexer(new Source('{ hello }'));
|
|
435
|
+
* const token = lexer.advance().toJSON();
|
|
436
|
+
*
|
|
437
|
+
* token; // => { kind: '{', value: undefined, line: 1, column: 1 }
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
toJSON(): {
|
|
441
|
+
kind: TokenKind;
|
|
442
|
+
value?: string;
|
|
443
|
+
line: number;
|
|
444
|
+
column: number;
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
/** An identifier in a GraphQL document. */
|
|
448
|
+
interface NameNode {
|
|
449
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
450
|
+
readonly kind: KindTypeMap['NAME'];
|
|
451
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
452
|
+
readonly loc?: Location | undefined;
|
|
453
|
+
/** Parsed value represented by this node. */
|
|
454
|
+
readonly value: string;
|
|
455
|
+
}
|
|
456
|
+
/** A query, mutation, or subscription operation definition. */
|
|
457
|
+
interface OperationDefinitionNode {
|
|
458
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
459
|
+
readonly kind: KindTypeMap['OPERATION_DEFINITION'];
|
|
460
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
461
|
+
readonly loc?: Location | undefined;
|
|
462
|
+
/** The optional GraphQL description associated with this definition. */
|
|
463
|
+
readonly description?: StringValueNode | undefined;
|
|
464
|
+
/** The operation selected for execution. */
|
|
465
|
+
readonly operation: OperationTypeNode;
|
|
466
|
+
/** Name node identifying this AST node. */
|
|
467
|
+
readonly name?: NameNode | undefined;
|
|
468
|
+
/** Variable definitions declared by this operation or fragment. */
|
|
469
|
+
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode> | undefined;
|
|
470
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
471
|
+
readonly directives?: ReadonlyArray<DirectiveNode> | undefined;
|
|
472
|
+
/** Selections made by this operation, field, or fragment. */
|
|
473
|
+
readonly selectionSet: SelectionSetNode;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* The operation types supported by GraphQL executable definitions.
|
|
477
|
+
* @category Kinds
|
|
478
|
+
*/
|
|
479
|
+
declare const OperationTypeNode: {
|
|
480
|
+
readonly QUERY: "query";
|
|
481
|
+
readonly MUTATION: "mutation";
|
|
482
|
+
readonly SUBSCRIPTION: "subscription";
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* The operation types supported by GraphQL executable definitions.
|
|
486
|
+
* @category Kinds
|
|
487
|
+
*/
|
|
488
|
+
type OperationTypeNode = (typeof OperationTypeNode)[keyof typeof OperationTypeNode];
|
|
489
|
+
/** A variable declaration in an operation or experimental fragment definition. */
|
|
490
|
+
interface VariableDefinitionNode {
|
|
491
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
492
|
+
readonly kind: KindTypeMap['VARIABLE_DEFINITION'];
|
|
493
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
494
|
+
readonly loc?: Location | undefined;
|
|
495
|
+
/** The optional GraphQL description associated with this definition. */
|
|
496
|
+
readonly description?: StringValueNode | undefined;
|
|
497
|
+
/** The variable being defined or referenced. */
|
|
498
|
+
readonly variable: VariableNode;
|
|
499
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
500
|
+
readonly type: TypeNode;
|
|
501
|
+
/** Default value used when no explicit value is supplied. */
|
|
502
|
+
readonly defaultValue?: ConstValueNode | undefined;
|
|
503
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
504
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
505
|
+
}
|
|
506
|
+
/** A variable reference, such as `$id`. */
|
|
507
|
+
interface VariableNode {
|
|
508
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
509
|
+
readonly kind: KindTypeMap['VARIABLE'];
|
|
510
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
511
|
+
readonly loc?: Location | undefined;
|
|
512
|
+
/** Name node identifying this AST node. */
|
|
513
|
+
readonly name: NameNode;
|
|
514
|
+
}
|
|
515
|
+
/** A set of fields and fragments selected from an object, interface, or union. */
|
|
516
|
+
interface SelectionSetNode {
|
|
517
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
518
|
+
kind: KindTypeMap['SELECTION_SET'];
|
|
519
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
520
|
+
loc?: Location | undefined;
|
|
521
|
+
/** Fields and fragments contained in this selection set. */
|
|
522
|
+
selections: ReadonlyArray<SelectionNode>;
|
|
523
|
+
}
|
|
524
|
+
/** Any selection that may appear inside a selection set. */
|
|
525
|
+
type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode;
|
|
526
|
+
/** A field selected in an executable GraphQL document. */
|
|
527
|
+
interface FieldNode {
|
|
528
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
529
|
+
readonly kind: KindTypeMap['FIELD'];
|
|
530
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
531
|
+
readonly loc?: Location | undefined;
|
|
532
|
+
/** The response-key alias for this field, if one was supplied. */
|
|
533
|
+
readonly alias?: NameNode | undefined;
|
|
534
|
+
/** Name node identifying this AST node. */
|
|
535
|
+
readonly name: NameNode;
|
|
536
|
+
/** Arguments supplied to this field, directive, or coordinate. */
|
|
537
|
+
readonly arguments?: ReadonlyArray<ArgumentNode> | undefined;
|
|
538
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
539
|
+
readonly directives?: ReadonlyArray<DirectiveNode> | undefined;
|
|
540
|
+
/** Selections made by this operation, field, or fragment. */
|
|
541
|
+
readonly selectionSet?: SelectionSetNode | undefined;
|
|
542
|
+
}
|
|
543
|
+
/** An argument supplied to a field or directive. */
|
|
544
|
+
interface ArgumentNode {
|
|
545
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
546
|
+
readonly kind: KindTypeMap['ARGUMENT'];
|
|
547
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
548
|
+
readonly loc?: Location | undefined;
|
|
549
|
+
/** Name node identifying this AST node. */
|
|
550
|
+
readonly name: NameNode;
|
|
551
|
+
/** Parsed value represented by this node. */
|
|
552
|
+
readonly value: ValueNode;
|
|
553
|
+
}
|
|
554
|
+
/** An argument node whose value is guaranteed to be constant. */
|
|
555
|
+
interface ConstArgumentNode {
|
|
556
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
557
|
+
readonly kind: KindTypeMap['ARGUMENT'];
|
|
558
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
559
|
+
readonly loc?: Location | undefined;
|
|
560
|
+
/** Name node identifying this AST node. */
|
|
561
|
+
readonly name: NameNode;
|
|
562
|
+
/** Parsed value represented by this node. */
|
|
563
|
+
readonly value: ConstValueNode;
|
|
564
|
+
}
|
|
565
|
+
/** Variable definition declared by a fragment argument. */
|
|
566
|
+
interface FragmentArgumentNode {
|
|
567
|
+
/** AST node kind for a fragment argument. */
|
|
568
|
+
readonly kind: KindTypeMap['FRAGMENT_ARGUMENT'];
|
|
569
|
+
/** Source location for this fragment argument. */
|
|
570
|
+
readonly loc?: Location | undefined;
|
|
571
|
+
/** Variable name declared by this fragment argument. */
|
|
572
|
+
readonly name: NameNode;
|
|
573
|
+
/** Default value literal for this fragment argument, if provided. */
|
|
574
|
+
readonly value: ValueNode;
|
|
575
|
+
}
|
|
576
|
+
/** A named fragment spread, such as `...userFields`. */
|
|
577
|
+
interface FragmentSpreadNode {
|
|
578
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
579
|
+
readonly kind: KindTypeMap['FRAGMENT_SPREAD'];
|
|
580
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
581
|
+
readonly loc?: Location | undefined;
|
|
582
|
+
/** Name node identifying this AST node. */
|
|
583
|
+
readonly name: NameNode;
|
|
584
|
+
/** Argument values supplied to the referenced fragment. */
|
|
585
|
+
readonly arguments?: ReadonlyArray<FragmentArgumentNode> | undefined;
|
|
586
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
587
|
+
readonly directives?: ReadonlyArray<DirectiveNode> | undefined;
|
|
588
|
+
}
|
|
589
|
+
/** An inline fragment spread with an optional type condition. */
|
|
590
|
+
interface InlineFragmentNode {
|
|
591
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
592
|
+
readonly kind: KindTypeMap['INLINE_FRAGMENT'];
|
|
593
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
594
|
+
readonly loc?: Location | undefined;
|
|
595
|
+
/** The type condition that limits where this fragment applies. */
|
|
596
|
+
readonly typeCondition?: NamedTypeNode | undefined;
|
|
597
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
598
|
+
readonly directives?: ReadonlyArray<DirectiveNode> | undefined;
|
|
599
|
+
/** Selections made by this operation, field, or fragment. */
|
|
600
|
+
readonly selectionSet: SelectionSetNode;
|
|
601
|
+
}
|
|
602
|
+
/** A reusable fragment definition declared in an executable document. */
|
|
603
|
+
interface FragmentDefinitionNode {
|
|
604
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
605
|
+
readonly kind: KindTypeMap['FRAGMENT_DEFINITION'];
|
|
606
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
607
|
+
readonly loc?: Location | undefined;
|
|
608
|
+
/** The optional GraphQL description associated with this definition. */
|
|
609
|
+
readonly description?: StringValueNode | undefined;
|
|
610
|
+
/** Name node identifying this AST node. */
|
|
611
|
+
readonly name: NameNode;
|
|
612
|
+
/** Experimental variable definitions declared by this fragment definition. */
|
|
613
|
+
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode> | undefined;
|
|
614
|
+
/** The type condition that limits where this fragment applies. */
|
|
615
|
+
readonly typeCondition: NamedTypeNode;
|
|
616
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
617
|
+
readonly directives?: ReadonlyArray<DirectiveNode> | undefined;
|
|
618
|
+
/** Selections made by this operation, field, or fragment. */
|
|
619
|
+
readonly selectionSet: SelectionSetNode;
|
|
620
|
+
}
|
|
621
|
+
/** Any value literal that may appear in an executable GraphQL document. */
|
|
622
|
+
type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
|
|
623
|
+
/** Any value literal that is guaranteed not to contain a variable reference. */
|
|
624
|
+
type ConstValueNode = IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ConstListValueNode | ConstObjectValueNode;
|
|
625
|
+
/** An integer value literal. */
|
|
626
|
+
interface IntValueNode {
|
|
627
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
628
|
+
readonly kind: KindTypeMap['INT'];
|
|
629
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
630
|
+
readonly loc?: Location | undefined;
|
|
631
|
+
/** Parsed value represented by this node. */
|
|
632
|
+
readonly value: string;
|
|
633
|
+
}
|
|
634
|
+
/** A floating-point value literal. */
|
|
635
|
+
interface FloatValueNode {
|
|
636
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
637
|
+
readonly kind: KindTypeMap['FLOAT'];
|
|
638
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
639
|
+
readonly loc?: Location | undefined;
|
|
640
|
+
/** Parsed value represented by this node. */
|
|
641
|
+
readonly value: string;
|
|
642
|
+
}
|
|
643
|
+
/** A string value literal. */
|
|
644
|
+
interface StringValueNode {
|
|
645
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
646
|
+
readonly kind: KindTypeMap['STRING'];
|
|
647
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
648
|
+
readonly loc?: Location | undefined;
|
|
649
|
+
/** Parsed value represented by this node. */
|
|
650
|
+
readonly value: string;
|
|
651
|
+
/** Whether this string was parsed from block string syntax. */
|
|
652
|
+
readonly block?: boolean | undefined;
|
|
653
|
+
}
|
|
654
|
+
/** A boolean value literal. */
|
|
655
|
+
interface BooleanValueNode {
|
|
656
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
657
|
+
readonly kind: KindTypeMap['BOOLEAN'];
|
|
658
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
659
|
+
readonly loc?: Location | undefined;
|
|
660
|
+
/** Parsed value represented by this node. */
|
|
661
|
+
readonly value: boolean;
|
|
662
|
+
}
|
|
663
|
+
/** A null value literal. */
|
|
664
|
+
interface NullValueNode {
|
|
665
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
666
|
+
readonly kind: KindTypeMap['NULL'];
|
|
667
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
668
|
+
readonly loc?: Location | undefined;
|
|
669
|
+
}
|
|
670
|
+
/** An enum value literal. */
|
|
671
|
+
interface EnumValueNode {
|
|
672
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
673
|
+
readonly kind: KindTypeMap['ENUM'];
|
|
674
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
675
|
+
readonly loc?: Location | undefined;
|
|
676
|
+
/** Parsed value represented by this node. */
|
|
677
|
+
readonly value: string;
|
|
678
|
+
}
|
|
679
|
+
/** A list value literal. */
|
|
680
|
+
interface ListValueNode {
|
|
681
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
682
|
+
readonly kind: KindTypeMap['LIST'];
|
|
683
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
684
|
+
readonly loc?: Location | undefined;
|
|
685
|
+
/** Values contained in this enum, list, or input-object definition. */
|
|
686
|
+
readonly values: ReadonlyArray<ValueNode>;
|
|
687
|
+
}
|
|
688
|
+
/** A list value literal whose elements are all constant values. */
|
|
689
|
+
interface ConstListValueNode {
|
|
690
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
691
|
+
readonly kind: KindTypeMap['LIST'];
|
|
692
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
693
|
+
readonly loc?: Location | undefined;
|
|
694
|
+
/** Values contained in this enum, list, or input-object definition. */
|
|
695
|
+
readonly values: ReadonlyArray<ConstValueNode>;
|
|
696
|
+
}
|
|
697
|
+
/** An input object value literal. */
|
|
698
|
+
interface ObjectValueNode {
|
|
699
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
700
|
+
readonly kind: KindTypeMap['OBJECT'];
|
|
701
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
702
|
+
readonly loc?: Location | undefined;
|
|
703
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
704
|
+
readonly fields: ReadonlyArray<ObjectFieldNode>;
|
|
705
|
+
}
|
|
706
|
+
/** An input object value literal whose fields are all constant values. */
|
|
707
|
+
interface ConstObjectValueNode {
|
|
708
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
709
|
+
readonly kind: KindTypeMap['OBJECT'];
|
|
710
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
711
|
+
readonly loc?: Location | undefined;
|
|
712
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
713
|
+
readonly fields: ReadonlyArray<ConstObjectFieldNode>;
|
|
714
|
+
}
|
|
715
|
+
/** A field inside an input object value literal. */
|
|
716
|
+
interface ObjectFieldNode {
|
|
717
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
718
|
+
readonly kind: KindTypeMap['OBJECT_FIELD'];
|
|
719
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
720
|
+
readonly loc?: Location | undefined;
|
|
721
|
+
/** Name node identifying this AST node. */
|
|
722
|
+
readonly name: NameNode;
|
|
723
|
+
/** Parsed value represented by this node. */
|
|
724
|
+
readonly value: ValueNode;
|
|
725
|
+
}
|
|
726
|
+
/** A field inside a constant input object value literal. */
|
|
727
|
+
interface ConstObjectFieldNode {
|
|
728
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
729
|
+
readonly kind: KindTypeMap['OBJECT_FIELD'];
|
|
730
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
731
|
+
readonly loc?: Location | undefined;
|
|
732
|
+
/** Name node identifying this AST node. */
|
|
733
|
+
readonly name: NameNode;
|
|
734
|
+
/** Parsed value represented by this node. */
|
|
735
|
+
readonly value: ConstValueNode;
|
|
736
|
+
}
|
|
737
|
+
/** A directive applied to an executable or type-system location. */
|
|
738
|
+
interface DirectiveNode {
|
|
739
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
740
|
+
readonly kind: KindTypeMap['DIRECTIVE'];
|
|
741
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
742
|
+
readonly loc?: Location | undefined;
|
|
743
|
+
/** Name node identifying this AST node. */
|
|
744
|
+
readonly name: NameNode;
|
|
745
|
+
/** Arguments supplied to this field, directive, or coordinate. */
|
|
746
|
+
readonly arguments?: ReadonlyArray<ArgumentNode> | undefined;
|
|
747
|
+
}
|
|
748
|
+
/** A directive whose arguments are all constant values. */
|
|
749
|
+
interface ConstDirectiveNode {
|
|
750
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
751
|
+
readonly kind: KindTypeMap['DIRECTIVE'];
|
|
752
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
753
|
+
readonly loc?: Location | undefined;
|
|
754
|
+
/** Name node identifying this AST node. */
|
|
755
|
+
readonly name: NameNode;
|
|
756
|
+
/** Arguments supplied to this field, directive, or coordinate. */
|
|
757
|
+
readonly arguments?: ReadonlyArray<ConstArgumentNode> | undefined;
|
|
758
|
+
}
|
|
759
|
+
/** Any GraphQL type reference AST node. */
|
|
760
|
+
type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
|
|
761
|
+
/** A named type reference. */
|
|
762
|
+
interface NamedTypeNode {
|
|
763
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
764
|
+
readonly kind: KindTypeMap['NAMED_TYPE'];
|
|
765
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
766
|
+
readonly loc?: Location | undefined;
|
|
767
|
+
/** Name node identifying this AST node. */
|
|
768
|
+
readonly name: NameNode;
|
|
769
|
+
}
|
|
770
|
+
/** A list type reference. */
|
|
771
|
+
interface ListTypeNode {
|
|
772
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
773
|
+
readonly kind: KindTypeMap['LIST_TYPE'];
|
|
774
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
775
|
+
readonly loc?: Location | undefined;
|
|
776
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
777
|
+
readonly type: TypeNode;
|
|
778
|
+
}
|
|
779
|
+
/** A non-null type reference. */
|
|
780
|
+
interface NonNullTypeNode {
|
|
781
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
782
|
+
readonly kind: KindTypeMap['NON_NULL_TYPE'];
|
|
783
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
784
|
+
readonly loc?: Location | undefined;
|
|
785
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
786
|
+
readonly type: NamedTypeNode | ListTypeNode;
|
|
787
|
+
}
|
|
788
|
+
/** A schema definition in a type-system document. */
|
|
789
|
+
interface SchemaDefinitionNode {
|
|
790
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
791
|
+
readonly kind: KindTypeMap['SCHEMA_DEFINITION'];
|
|
792
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
793
|
+
readonly loc?: Location | undefined;
|
|
794
|
+
/** The optional GraphQL description associated with this definition. */
|
|
795
|
+
readonly description?: StringValueNode | undefined;
|
|
796
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
797
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
798
|
+
/** Root operation types declared by this schema definition or extension. */
|
|
799
|
+
readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>;
|
|
800
|
+
}
|
|
801
|
+
/** A root operation type declaration inside a schema definition or extension. */
|
|
802
|
+
interface OperationTypeDefinitionNode {
|
|
803
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
804
|
+
readonly kind: KindTypeMap['OPERATION_TYPE_DEFINITION'];
|
|
805
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
806
|
+
readonly loc?: Location | undefined;
|
|
807
|
+
/** The operation selected for execution. */
|
|
808
|
+
readonly operation: OperationTypeNode;
|
|
809
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
810
|
+
readonly type: NamedTypeNode;
|
|
811
|
+
}
|
|
812
|
+
/** A scalar type definition in a type-system document. */
|
|
813
|
+
interface ScalarTypeDefinitionNode {
|
|
814
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
815
|
+
readonly kind: KindTypeMap['SCALAR_TYPE_DEFINITION'];
|
|
816
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
817
|
+
readonly loc?: Location | undefined;
|
|
818
|
+
/** The optional GraphQL description associated with this definition. */
|
|
819
|
+
readonly description?: StringValueNode | undefined;
|
|
820
|
+
/** Name node identifying this AST node. */
|
|
821
|
+
readonly name: NameNode;
|
|
822
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
823
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
824
|
+
}
|
|
825
|
+
/** An object type definition in a type-system document. */
|
|
826
|
+
interface ObjectTypeDefinitionNode {
|
|
827
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
828
|
+
readonly kind: KindTypeMap['OBJECT_TYPE_DEFINITION'];
|
|
829
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
830
|
+
readonly loc?: Location | undefined;
|
|
831
|
+
/** The optional GraphQL description associated with this definition. */
|
|
832
|
+
readonly description?: StringValueNode | undefined;
|
|
833
|
+
/** Name node identifying this AST node. */
|
|
834
|
+
readonly name: NameNode;
|
|
835
|
+
/** Interfaces implemented by this object or interface type. */
|
|
836
|
+
readonly interfaces?: ReadonlyArray<NamedTypeNode> | undefined;
|
|
837
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
838
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
839
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
840
|
+
readonly fields?: ReadonlyArray<FieldDefinitionNode> | undefined;
|
|
841
|
+
}
|
|
842
|
+
/** A field definition declared by an object or interface type. */
|
|
843
|
+
interface FieldDefinitionNode {
|
|
844
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
845
|
+
readonly kind: KindTypeMap['FIELD_DEFINITION'];
|
|
846
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
847
|
+
readonly loc?: Location | undefined;
|
|
848
|
+
/** The optional GraphQL description associated with this definition. */
|
|
849
|
+
readonly description?: StringValueNode | undefined;
|
|
850
|
+
/** Name node identifying this AST node. */
|
|
851
|
+
readonly name: NameNode;
|
|
852
|
+
/** Arguments supplied to this field, directive, or coordinate. */
|
|
853
|
+
readonly arguments?: ReadonlyArray<InputValueDefinitionNode> | undefined;
|
|
854
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
855
|
+
readonly type: TypeNode;
|
|
856
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
857
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
858
|
+
}
|
|
859
|
+
/** An argument or input-field definition. */
|
|
860
|
+
interface InputValueDefinitionNode {
|
|
861
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
862
|
+
readonly kind: KindTypeMap['INPUT_VALUE_DEFINITION'];
|
|
863
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
864
|
+
readonly loc?: Location | undefined;
|
|
865
|
+
/** The optional GraphQL description associated with this definition. */
|
|
866
|
+
readonly description?: StringValueNode | undefined;
|
|
867
|
+
/** Name node identifying this AST node. */
|
|
868
|
+
readonly name: NameNode;
|
|
869
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
870
|
+
readonly type: TypeNode;
|
|
871
|
+
/** Default value used when no explicit value is supplied. */
|
|
872
|
+
readonly defaultValue?: ConstValueNode | undefined;
|
|
873
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
874
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
875
|
+
}
|
|
876
|
+
/** An interface type definition in a type-system document. */
|
|
877
|
+
interface InterfaceTypeDefinitionNode {
|
|
878
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
879
|
+
readonly kind: KindTypeMap['INTERFACE_TYPE_DEFINITION'];
|
|
880
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
881
|
+
readonly loc?: Location | undefined;
|
|
882
|
+
/** The optional GraphQL description associated with this definition. */
|
|
883
|
+
readonly description?: StringValueNode | undefined;
|
|
884
|
+
/** Name node identifying this AST node. */
|
|
885
|
+
readonly name: NameNode;
|
|
886
|
+
/** Interfaces implemented by this object or interface type. */
|
|
887
|
+
readonly interfaces?: ReadonlyArray<NamedTypeNode> | undefined;
|
|
888
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
889
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
890
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
891
|
+
readonly fields?: ReadonlyArray<FieldDefinitionNode> | undefined;
|
|
892
|
+
}
|
|
893
|
+
/** A union type definition in a type-system document. */
|
|
894
|
+
interface UnionTypeDefinitionNode {
|
|
895
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
896
|
+
readonly kind: KindTypeMap['UNION_TYPE_DEFINITION'];
|
|
897
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
898
|
+
readonly loc?: Location | undefined;
|
|
899
|
+
/** The optional GraphQL description associated with this definition. */
|
|
900
|
+
readonly description?: StringValueNode | undefined;
|
|
901
|
+
/** Name node identifying this AST node. */
|
|
902
|
+
readonly name: NameNode;
|
|
903
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
904
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
905
|
+
/** Object types that belong to this union type. */
|
|
906
|
+
readonly types?: ReadonlyArray<NamedTypeNode> | undefined;
|
|
907
|
+
}
|
|
908
|
+
/** An enum type definition in a type-system document. */
|
|
909
|
+
interface EnumTypeDefinitionNode {
|
|
910
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
911
|
+
readonly kind: KindTypeMap['ENUM_TYPE_DEFINITION'];
|
|
912
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
913
|
+
readonly loc?: Location | undefined;
|
|
914
|
+
/** The optional GraphQL description associated with this definition. */
|
|
915
|
+
readonly description?: StringValueNode | undefined;
|
|
916
|
+
/** Name node identifying this AST node. */
|
|
917
|
+
readonly name: NameNode;
|
|
918
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
919
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
920
|
+
/** Values contained in this enum, list, or input-object definition. */
|
|
921
|
+
readonly values?: ReadonlyArray<EnumValueDefinitionNode> | undefined;
|
|
922
|
+
}
|
|
923
|
+
/** An enum value definition. */
|
|
924
|
+
interface EnumValueDefinitionNode {
|
|
925
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
926
|
+
readonly kind: KindTypeMap['ENUM_VALUE_DEFINITION'];
|
|
927
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
928
|
+
readonly loc?: Location | undefined;
|
|
929
|
+
/** The optional GraphQL description associated with this definition. */
|
|
930
|
+
readonly description?: StringValueNode | undefined;
|
|
931
|
+
/** Name node identifying this AST node. */
|
|
932
|
+
readonly name: NameNode;
|
|
933
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
934
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
935
|
+
}
|
|
936
|
+
/** An input object type definition in a type-system document. */
|
|
937
|
+
interface InputObjectTypeDefinitionNode {
|
|
938
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
939
|
+
readonly kind: KindTypeMap['INPUT_OBJECT_TYPE_DEFINITION'];
|
|
940
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
941
|
+
readonly loc?: Location | undefined;
|
|
942
|
+
/** The optional GraphQL description associated with this definition. */
|
|
943
|
+
readonly description?: StringValueNode | undefined;
|
|
944
|
+
/** Name node identifying this AST node. */
|
|
945
|
+
readonly name: NameNode;
|
|
946
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
947
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
948
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
949
|
+
readonly fields?: ReadonlyArray<InputValueDefinitionNode> | undefined;
|
|
950
|
+
}
|
|
951
|
+
/** A directive definition in a type-system document. */
|
|
952
|
+
interface DirectiveDefinitionNode {
|
|
953
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
954
|
+
readonly kind: KindTypeMap['DIRECTIVE_DEFINITION'];
|
|
955
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
956
|
+
readonly loc?: Location | undefined;
|
|
957
|
+
/** The optional GraphQL description associated with this definition. */
|
|
958
|
+
readonly description?: StringValueNode | undefined;
|
|
959
|
+
/** Name node identifying this AST node. */
|
|
960
|
+
readonly name: NameNode;
|
|
961
|
+
/** Arguments supplied to this field, directive, or coordinate. */
|
|
962
|
+
readonly arguments?: ReadonlyArray<InputValueDefinitionNode> | undefined;
|
|
963
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
964
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
965
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
966
|
+
readonly repeatable: boolean;
|
|
967
|
+
/** Locations where this directive may be applied. */
|
|
968
|
+
readonly locations: ReadonlyArray<NameNode>;
|
|
969
|
+
}
|
|
970
|
+
/** A schema extension in a type-system document. */
|
|
971
|
+
interface SchemaExtensionNode {
|
|
972
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
973
|
+
readonly kind: KindTypeMap['SCHEMA_EXTENSION'];
|
|
974
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
975
|
+
readonly loc?: Location | undefined;
|
|
976
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
977
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
978
|
+
/** Root operation types declared by this schema definition or extension. */
|
|
979
|
+
readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode> | undefined;
|
|
980
|
+
}
|
|
981
|
+
/** A scalar type extension. */
|
|
982
|
+
interface ScalarTypeExtensionNode {
|
|
983
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
984
|
+
readonly kind: KindTypeMap['SCALAR_TYPE_EXTENSION'];
|
|
985
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
986
|
+
readonly loc?: Location | undefined;
|
|
987
|
+
/** Name node identifying this AST node. */
|
|
988
|
+
readonly name: NameNode;
|
|
989
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
990
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
991
|
+
}
|
|
992
|
+
/** An object type extension. */
|
|
993
|
+
interface ObjectTypeExtensionNode {
|
|
994
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
995
|
+
readonly kind: KindTypeMap['OBJECT_TYPE_EXTENSION'];
|
|
996
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
997
|
+
readonly loc?: Location | undefined;
|
|
998
|
+
/** Name node identifying this AST node. */
|
|
999
|
+
readonly name: NameNode;
|
|
1000
|
+
/** Interfaces implemented by this object or interface type. */
|
|
1001
|
+
readonly interfaces?: ReadonlyArray<NamedTypeNode> | undefined;
|
|
1002
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
1003
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
1004
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
1005
|
+
readonly fields?: ReadonlyArray<FieldDefinitionNode> | undefined;
|
|
1006
|
+
}
|
|
1007
|
+
/** An interface type extension. */
|
|
1008
|
+
interface InterfaceTypeExtensionNode {
|
|
1009
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
1010
|
+
readonly kind: KindTypeMap['INTERFACE_TYPE_EXTENSION'];
|
|
1011
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
1012
|
+
readonly loc?: Location | undefined;
|
|
1013
|
+
/** Name node identifying this AST node. */
|
|
1014
|
+
readonly name: NameNode;
|
|
1015
|
+
/** Interfaces implemented by this object or interface type. */
|
|
1016
|
+
readonly interfaces?: ReadonlyArray<NamedTypeNode> | undefined;
|
|
1017
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
1018
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
1019
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
1020
|
+
readonly fields?: ReadonlyArray<FieldDefinitionNode> | undefined;
|
|
1021
|
+
}
|
|
1022
|
+
/** A union type extension. */
|
|
1023
|
+
interface UnionTypeExtensionNode {
|
|
1024
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
1025
|
+
readonly kind: KindTypeMap['UNION_TYPE_EXTENSION'];
|
|
1026
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
1027
|
+
readonly loc?: Location | undefined;
|
|
1028
|
+
/** Name node identifying this AST node. */
|
|
1029
|
+
readonly name: NameNode;
|
|
1030
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
1031
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
1032
|
+
/** Object types that belong to this union type. */
|
|
1033
|
+
readonly types?: ReadonlyArray<NamedTypeNode> | undefined;
|
|
1034
|
+
}
|
|
1035
|
+
/** An enum type extension. */
|
|
1036
|
+
interface EnumTypeExtensionNode {
|
|
1037
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
1038
|
+
readonly kind: KindTypeMap['ENUM_TYPE_EXTENSION'];
|
|
1039
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
1040
|
+
readonly loc?: Location | undefined;
|
|
1041
|
+
/** Name node identifying this AST node. */
|
|
1042
|
+
readonly name: NameNode;
|
|
1043
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
1044
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
1045
|
+
/** Values contained in this enum, list, or input-object definition. */
|
|
1046
|
+
readonly values?: ReadonlyArray<EnumValueDefinitionNode> | undefined;
|
|
1047
|
+
}
|
|
1048
|
+
/** An input object type extension. */
|
|
1049
|
+
interface InputObjectTypeExtensionNode {
|
|
1050
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
1051
|
+
readonly kind: KindTypeMap['INPUT_OBJECT_TYPE_EXTENSION'];
|
|
1052
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
1053
|
+
readonly loc?: Location | undefined;
|
|
1054
|
+
/** Name node identifying this AST node. */
|
|
1055
|
+
readonly name: NameNode;
|
|
1056
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
1057
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
1058
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
1059
|
+
readonly fields?: ReadonlyArray<InputValueDefinitionNode> | undefined;
|
|
1060
|
+
}
|
|
1061
|
+
/** A directive extension. */
|
|
1062
|
+
interface DirectiveExtensionNode {
|
|
1063
|
+
/** The discriminator identifying the concrete AST or introspection kind. */
|
|
1064
|
+
readonly kind: KindTypeMap['DIRECTIVE_EXTENSION'];
|
|
1065
|
+
/** The source location for this AST node, if location tracking was enabled. */
|
|
1066
|
+
readonly loc?: Location | undefined;
|
|
1067
|
+
/** Name node identifying this AST node. */
|
|
1068
|
+
readonly name: NameNode;
|
|
1069
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
1070
|
+
readonly directives?: ReadonlyArray<ConstDirectiveNode> | undefined;
|
|
1071
|
+
}
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/jsutils/Path.d.ts
|
|
1074
|
+
/** Represents a linked response path from a field back to the root response. */
|
|
1075
|
+
interface Path {
|
|
1076
|
+
/** The previous segment in the linked response path, or undefined at the root. */
|
|
1077
|
+
readonly prev: Path | undefined;
|
|
1078
|
+
/** The field name or list index for this response path segment. */
|
|
1079
|
+
readonly key: string | number;
|
|
1080
|
+
/** The runtime object type name associated with this path segment, if known. */
|
|
1081
|
+
readonly typename: string | undefined;
|
|
1082
|
+
}
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/jsutils/PromiseOrValue.d.ts
|
|
1085
|
+
/** @internal */
|
|
1086
|
+
type PromiseOrValue<T> = Promise<T> | T;
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/language/directiveLocation.d.ts
|
|
1089
|
+
/** @category Kinds */
|
|
1090
|
+
/** The set of allowed directive location values. */
|
|
1091
|
+
declare const DirectiveLocation: {
|
|
1092
|
+
/** Directive location for query operations. */readonly QUERY: "QUERY"; /** Directive location for mutation operations. */
|
|
1093
|
+
readonly MUTATION: "MUTATION"; /** Directive location for subscription operations. */
|
|
1094
|
+
readonly SUBSCRIPTION: "SUBSCRIPTION"; /** Directive location for field selections. */
|
|
1095
|
+
readonly FIELD: "FIELD"; /** Directive location for fragment definitions. */
|
|
1096
|
+
readonly FRAGMENT_DEFINITION: "FRAGMENT_DEFINITION"; /** Directive location for fragment spreads. */
|
|
1097
|
+
readonly FRAGMENT_SPREAD: "FRAGMENT_SPREAD"; /** Directive location for inline fragments. */
|
|
1098
|
+
readonly INLINE_FRAGMENT: "INLINE_FRAGMENT"; /** Directive location for variable definitions. */
|
|
1099
|
+
readonly VARIABLE_DEFINITION: "VARIABLE_DEFINITION"; /** Directive location for fragment variable definitions. */
|
|
1100
|
+
readonly FRAGMENT_VARIABLE_DEFINITION: "FRAGMENT_VARIABLE_DEFINITION"; /** Directive location for schema definitions and extensions. */
|
|
1101
|
+
readonly SCHEMA: "SCHEMA"; /** Directive location for scalar type definitions and extensions. */
|
|
1102
|
+
readonly SCALAR: "SCALAR"; /** Directive location for object type definitions and extensions. */
|
|
1103
|
+
readonly OBJECT: "OBJECT"; /** Directive location for field definitions. */
|
|
1104
|
+
readonly FIELD_DEFINITION: "FIELD_DEFINITION"; /** Directive location for argument definitions. */
|
|
1105
|
+
readonly ARGUMENT_DEFINITION: "ARGUMENT_DEFINITION"; /** Directive location for interface type definitions and extensions. */
|
|
1106
|
+
readonly INTERFACE: "INTERFACE"; /** Directive location for union type definitions and extensions. */
|
|
1107
|
+
readonly UNION: "UNION"; /** Directive location for enum type definitions and extensions. */
|
|
1108
|
+
readonly ENUM: "ENUM"; /** Directive location for enum value definitions. */
|
|
1109
|
+
readonly ENUM_VALUE: "ENUM_VALUE"; /** Directive location for input object type definitions and extensions. */
|
|
1110
|
+
readonly INPUT_OBJECT: "INPUT_OBJECT"; /** Directive location for input object field definitions. */
|
|
1111
|
+
readonly INPUT_FIELD_DEFINITION: "INPUT_FIELD_DEFINITION"; /** Directive location for directive definitions and extensions. */
|
|
1112
|
+
readonly DIRECTIVE_DEFINITION: "DIRECTIVE_DEFINITION";
|
|
1113
|
+
};
|
|
1114
|
+
/** The set of allowed directive location values. */
|
|
1115
|
+
type DirectiveLocation = (typeof DirectiveLocation)[keyof typeof DirectiveLocation];
|
|
1116
|
+
//#endregion
|
|
1117
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/type/directives.d.ts
|
|
1118
|
+
/**
|
|
1119
|
+
* Custom extensions
|
|
1120
|
+
* @remarks
|
|
1121
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
1122
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
1123
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
1124
|
+
* an object which can contain all the values you need.
|
|
1125
|
+
*/
|
|
1126
|
+
interface GraphQLDirectiveExtensions {
|
|
1127
|
+
[attributeName: string | symbol]: unknown;
|
|
1128
|
+
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Directives are used by the GraphQL runtime as a way of modifying execution
|
|
1131
|
+
* behavior. Type system creators will usually not create these directly.
|
|
1132
|
+
*/
|
|
1133
|
+
declare class GraphQLDirective implements GraphQLSchemaElement {
|
|
1134
|
+
/** The GraphQL name for this schema element. */
|
|
1135
|
+
name: string;
|
|
1136
|
+
/** Human-readable description for this schema element, if provided. */
|
|
1137
|
+
description: Maybe<string>;
|
|
1138
|
+
/** Locations where this directive may be applied. */
|
|
1139
|
+
locations: ReadonlyArray<DirectiveLocation>;
|
|
1140
|
+
/** Arguments accepted by this field or directive. */
|
|
1141
|
+
args: ReadonlyArray<GraphQLArgument>;
|
|
1142
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
1143
|
+
isRepeatable: boolean;
|
|
1144
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
1145
|
+
deprecationReason: Maybe<string>;
|
|
1146
|
+
/** Custom extension fields reserved for users. */
|
|
1147
|
+
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
1148
|
+
/** AST node from which this schema element was built, if available. */
|
|
1149
|
+
astNode: Maybe<DirectiveDefinitionNode>;
|
|
1150
|
+
/** AST extension nodes applied to this schema element. */
|
|
1151
|
+
extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;
|
|
1152
|
+
/**
|
|
1153
|
+
* Creates a GraphQLDirective instance.
|
|
1154
|
+
* @param config - Configuration describing this object.
|
|
1155
|
+
* @example
|
|
1156
|
+
* ```ts
|
|
1157
|
+
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
1158
|
+
* import {
|
|
1159
|
+
* GraphQLBoolean,
|
|
1160
|
+
* GraphQLDirective,
|
|
1161
|
+
* GraphQLInt,
|
|
1162
|
+
* GraphQLNonNull,
|
|
1163
|
+
* } from 'graphql/type';
|
|
1164
|
+
*
|
|
1165
|
+
* const document = parse(`
|
|
1166
|
+
* directive @cacheControl(maxAge: Int) repeatable on FIELD_DEFINITION
|
|
1167
|
+
* extend directive @cacheControl(maxAge: Int) on FIELD_DEFINITION
|
|
1168
|
+
* `);
|
|
1169
|
+
* const definition = document.definitions[0];
|
|
1170
|
+
*
|
|
1171
|
+
* const cacheControl = new GraphQLDirective({
|
|
1172
|
+
* name: 'cacheControl',
|
|
1173
|
+
* description: 'Controls HTTP cache hints for a field.',
|
|
1174
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
1175
|
+
* args: {
|
|
1176
|
+
* inheritMaxAge: {
|
|
1177
|
+
* description: 'Inherit the parent cache hint.',
|
|
1178
|
+
* type: new GraphQLNonNull(GraphQLBoolean),
|
|
1179
|
+
* default: { value: false },
|
|
1180
|
+
* deprecationReason: 'Use maxAge instead.',
|
|
1181
|
+
* extensions: { scope: 'cache' },
|
|
1182
|
+
* },
|
|
1183
|
+
* maxAge: {
|
|
1184
|
+
* type: GraphQLInt,
|
|
1185
|
+
* astNode: definition.arguments[0],
|
|
1186
|
+
* },
|
|
1187
|
+
* },
|
|
1188
|
+
* isRepeatable: true,
|
|
1189
|
+
* deprecationReason: 'Use @cache instead.',
|
|
1190
|
+
* extensions: { scope: 'cache' },
|
|
1191
|
+
* astNode: definition,
|
|
1192
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
1193
|
+
* });
|
|
1194
|
+
*
|
|
1195
|
+
* cacheControl.name; // => 'cacheControl'
|
|
1196
|
+
* cacheControl.description; // => 'Controls HTTP cache hints for a field.'
|
|
1197
|
+
* cacheControl.args[0].name; // => 'inheritMaxAge'
|
|
1198
|
+
* cacheControl.args[0].default.value; // => false
|
|
1199
|
+
* cacheControl.isRepeatable; // => true
|
|
1200
|
+
* cacheControl.extensions; // => { scope: 'cache' }
|
|
1201
|
+
* ```
|
|
1202
|
+
*/
|
|
1203
|
+
constructor(config: Readonly<GraphQLDirectiveConfig>);
|
|
1204
|
+
/**
|
|
1205
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1206
|
+
* @returns The built-in string tag for this object.
|
|
1207
|
+
*/
|
|
1208
|
+
get [Symbol.toStringTag](): string;
|
|
1209
|
+
/**
|
|
1210
|
+
* Returns a normalized configuration object for this object.
|
|
1211
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
1212
|
+
* @example
|
|
1213
|
+
* ```ts
|
|
1214
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
1215
|
+
* import { GraphQLDirective, GraphQLString } from 'graphql/type';
|
|
1216
|
+
*
|
|
1217
|
+
* const tag = new GraphQLDirective({
|
|
1218
|
+
* name: 'tag',
|
|
1219
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
1220
|
+
* args: {
|
|
1221
|
+
* name: { type: GraphQLString },
|
|
1222
|
+
* },
|
|
1223
|
+
* });
|
|
1224
|
+
*
|
|
1225
|
+
* const config = tag.toConfig();
|
|
1226
|
+
* const tagCopy = new GraphQLDirective(config);
|
|
1227
|
+
*
|
|
1228
|
+
* config.args.name.type; // => GraphQLString
|
|
1229
|
+
* tagCopy.args[0].name; // => 'name'
|
|
1230
|
+
* ```
|
|
1231
|
+
*/
|
|
1232
|
+
toConfig(): GraphQLDirectiveNormalizedConfig;
|
|
1233
|
+
/**
|
|
1234
|
+
* Returns the schema coordinate identifying this directive.
|
|
1235
|
+
* @returns The directive schema coordinate.
|
|
1236
|
+
* @example
|
|
1237
|
+
* ```ts
|
|
1238
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
1239
|
+
* import { GraphQLDirective } from 'graphql/type';
|
|
1240
|
+
*
|
|
1241
|
+
* const tag = new GraphQLDirective({
|
|
1242
|
+
* name: 'tag',
|
|
1243
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
1244
|
+
* });
|
|
1245
|
+
*
|
|
1246
|
+
* tag.toString(); // => '@tag'
|
|
1247
|
+
* ```
|
|
1248
|
+
*/
|
|
1249
|
+
toString(): string;
|
|
1250
|
+
/**
|
|
1251
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1252
|
+
* @returns The JSON-serializable representation.
|
|
1253
|
+
* @example
|
|
1254
|
+
* ```ts
|
|
1255
|
+
* import { DirectiveLocation } from 'graphql/language';
|
|
1256
|
+
* import { GraphQLDirective } from 'graphql/type';
|
|
1257
|
+
*
|
|
1258
|
+
* const tag = new GraphQLDirective({
|
|
1259
|
+
* name: 'tag',
|
|
1260
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
1261
|
+
* });
|
|
1262
|
+
*
|
|
1263
|
+
* tag.toJSON(); // => '@tag'
|
|
1264
|
+
* JSON.stringify({ directive: tag }); // => '{"directive":"@tag"}'
|
|
1265
|
+
* ```
|
|
1266
|
+
*/
|
|
1267
|
+
toJSON(): string;
|
|
1268
|
+
}
|
|
1269
|
+
/** Configuration used to construct a GraphQLDirective. */
|
|
1270
|
+
interface GraphQLDirectiveConfig {
|
|
1271
|
+
/** The GraphQL name for this schema element. */
|
|
1272
|
+
name: string;
|
|
1273
|
+
/** Human-readable description for this schema element, if provided. */
|
|
1274
|
+
description?: Maybe<string>;
|
|
1275
|
+
/** Locations where this directive may be applied. */
|
|
1276
|
+
locations: ReadonlyArray<DirectiveLocation>;
|
|
1277
|
+
/** Arguments accepted by this field or directive. */
|
|
1278
|
+
args?: Maybe<ObjMap<GraphQLArgumentConfig>>;
|
|
1279
|
+
/** Whether this directive may appear more than once at the same location. */
|
|
1280
|
+
isRepeatable?: Maybe<boolean>;
|
|
1281
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
1282
|
+
deprecationReason?: Maybe<string>;
|
|
1283
|
+
/** Custom extension fields reserved for users. */
|
|
1284
|
+
extensions?: Maybe<Readonly<GraphQLDirectiveExtensions>>;
|
|
1285
|
+
/** AST node from which this schema element was built, if available. */
|
|
1286
|
+
astNode?: Maybe<DirectiveDefinitionNode>;
|
|
1287
|
+
/** AST extension nodes applied to this schema element. */
|
|
1288
|
+
extensionASTNodes?: Maybe<ReadonlyArray<DirectiveExtensionNode>>;
|
|
1289
|
+
}
|
|
1290
|
+
/** @internal */
|
|
1291
|
+
interface GraphQLDirectiveNormalizedConfig extends GraphQLDirectiveConfig {
|
|
1292
|
+
args: GraphQLFieldNormalizedConfigArgumentMap;
|
|
1293
|
+
isRepeatable: boolean;
|
|
1294
|
+
extensions: Readonly<GraphQLDirectiveExtensions>;
|
|
1295
|
+
extensionASTNodes: ReadonlyArray<DirectiveExtensionNode>;
|
|
1296
|
+
}
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/execution/getVariableSignature.d.ts
|
|
1299
|
+
/**
|
|
1300
|
+
* A GraphQLVariableSignature is required to coerce a variable value.
|
|
1301
|
+
*
|
|
1302
|
+
* Designed to have comparable interface to GraphQLArgument so that
|
|
1303
|
+
* getArgumentValues() can be reused for fragment arguments.
|
|
1304
|
+
*
|
|
1305
|
+
* @internal
|
|
1306
|
+
*/
|
|
1307
|
+
interface GraphQLVariableSignature {
|
|
1308
|
+
name: string;
|
|
1309
|
+
type: GraphQLInputType;
|
|
1310
|
+
defaultValue?: never;
|
|
1311
|
+
default: {
|
|
1312
|
+
literal: ConstValueNode;
|
|
1313
|
+
} | undefined;
|
|
1314
|
+
}
|
|
1315
|
+
//#endregion
|
|
1316
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/execution/values.d.ts
|
|
1317
|
+
/**
|
|
1318
|
+
* Coerced variable values prepared for execution.
|
|
1319
|
+
*
|
|
1320
|
+
* The `coerced` map contains runtime values keyed by variable name. The
|
|
1321
|
+
* `sources` map records whether each value came from request input, an operation
|
|
1322
|
+
* default, or a fragment-variable default so utilities can preserve defaults
|
|
1323
|
+
* when replacing variables in literals.
|
|
1324
|
+
*/
|
|
1325
|
+
interface VariableValues {
|
|
1326
|
+
/** Source metadata for each variable value keyed by variable name. */
|
|
1327
|
+
readonly sources: ReadOnlyObjMap<VariableValueSource>;
|
|
1328
|
+
/** Coerced runtime variable values keyed by variable name. */
|
|
1329
|
+
readonly coerced: ReadOnlyObjMap<unknown>;
|
|
1330
|
+
}
|
|
1331
|
+
interface VariableValueSource {
|
|
1332
|
+
readonly signature: GraphQLVariableSignature;
|
|
1333
|
+
readonly value?: unknown;
|
|
1334
|
+
}
|
|
1335
|
+
//#endregion
|
|
1336
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/type/definition.d.ts
|
|
1337
|
+
/** These are all of the possible kinds of types. */
|
|
1338
|
+
type GraphQLType = GraphQLNamedType | GraphQLWrappingType;
|
|
1339
|
+
/** These types may be used as input types for arguments and directives. */
|
|
1340
|
+
type GraphQLNullableInputType = GraphQLNamedInputType | GraphQLList<GraphQLInputType>;
|
|
1341
|
+
/** These types may be used as input types for arguments and directives. */
|
|
1342
|
+
type GraphQLInputType = GraphQLNullableInputType | GraphQLNonNull<GraphQLNullableInputType>;
|
|
1343
|
+
/** These types may be used as output types as the result of fields. */
|
|
1344
|
+
type GraphQLNullableOutputType = GraphQLNamedOutputType | GraphQLList<GraphQLOutputType>;
|
|
1345
|
+
/** These types may be used as output types as the result of fields. */
|
|
1346
|
+
type GraphQLOutputType = GraphQLNullableOutputType | GraphQLNonNull<GraphQLNullableOutputType>;
|
|
1347
|
+
/** These types may describe the parent context of a selection set. */
|
|
1348
|
+
type GraphQLCompositeType = GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType;
|
|
1349
|
+
/** These types may describe the parent context of a selection set. */
|
|
1350
|
+
type GraphQLAbstractType = GraphQLInterfaceType | GraphQLUnionType;
|
|
1351
|
+
/**
|
|
1352
|
+
* List Type Wrapper
|
|
1353
|
+
*
|
|
1354
|
+
* A list is a wrapping type which points to another type.
|
|
1355
|
+
* Lists are often created within the context of defining the fields of
|
|
1356
|
+
* an object type.
|
|
1357
|
+
* @typeParam T - The GraphQL type wrapped by this list type.
|
|
1358
|
+
* @example
|
|
1359
|
+
* ```ts
|
|
1360
|
+
* const PersonType = new GraphQLObjectType({
|
|
1361
|
+
* name: 'Person',
|
|
1362
|
+
* fields: () => ({
|
|
1363
|
+
* parents: { type: new GraphQLList(PersonType) },
|
|
1364
|
+
* children: { type: new GraphQLList(PersonType) },
|
|
1365
|
+
* }),
|
|
1366
|
+
* });
|
|
1367
|
+
* ```
|
|
1368
|
+
*/
|
|
1369
|
+
declare class GraphQLList<T extends GraphQLType> implements GraphQLSchemaElement {
|
|
1370
|
+
/** The type wrapped by this list or non-null type. */
|
|
1371
|
+
readonly ofType: T;
|
|
1372
|
+
private readonly __GraphQLListTypeBrand;
|
|
1373
|
+
/**
|
|
1374
|
+
* Creates a GraphQLList instance.
|
|
1375
|
+
* @param ofType - The type to wrap.
|
|
1376
|
+
* @example
|
|
1377
|
+
* ```ts
|
|
1378
|
+
* import { GraphQLList, GraphQLString } from 'graphql/type';
|
|
1379
|
+
*
|
|
1380
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1381
|
+
*
|
|
1382
|
+
* stringList.ofType; // => GraphQLString
|
|
1383
|
+
* String(stringList); // => '[String]'
|
|
1384
|
+
* ```
|
|
1385
|
+
*/
|
|
1386
|
+
constructor(ofType: T);
|
|
1387
|
+
/**
|
|
1388
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1389
|
+
* @returns The built-in string tag for this object.
|
|
1390
|
+
*/
|
|
1391
|
+
get [Symbol.toStringTag](): string;
|
|
1392
|
+
/**
|
|
1393
|
+
* Returns this wrapping type as a GraphQL type-reference string.
|
|
1394
|
+
* @returns The GraphQL type-reference string.
|
|
1395
|
+
* @example
|
|
1396
|
+
* ```ts
|
|
1397
|
+
* import { GraphQLList, GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1398
|
+
*
|
|
1399
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1400
|
+
* const requiredStringList = new GraphQLList(new GraphQLNonNull(GraphQLString));
|
|
1401
|
+
*
|
|
1402
|
+
* stringList.toString(); // => '[String]'
|
|
1403
|
+
* requiredStringList.toString(); // => '[String!]'
|
|
1404
|
+
* ```
|
|
1405
|
+
*/
|
|
1406
|
+
toString(): string;
|
|
1407
|
+
/**
|
|
1408
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1409
|
+
* @returns The JSON-serializable representation.
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```ts
|
|
1412
|
+
* import { GraphQLList, GraphQLString } from 'graphql/type';
|
|
1413
|
+
*
|
|
1414
|
+
* const stringList = new GraphQLList(GraphQLString);
|
|
1415
|
+
*
|
|
1416
|
+
* stringList.toJSON(); // => '[String]'
|
|
1417
|
+
* JSON.stringify({ type: stringList }); // => '{"type":"[String]"}'
|
|
1418
|
+
* ```
|
|
1419
|
+
*/
|
|
1420
|
+
toJSON(): string;
|
|
1421
|
+
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Non-Null Type Wrapper
|
|
1424
|
+
*
|
|
1425
|
+
* A non-null is a wrapping type which points to another type.
|
|
1426
|
+
* Non-null types enforce that their values are never null and can ensure
|
|
1427
|
+
* an error is raised if this ever occurs during a request. It is useful for
|
|
1428
|
+
* fields which you can make a strong guarantee on non-nullability, for example
|
|
1429
|
+
* usually the id field of a database row will never be null.
|
|
1430
|
+
* @typeParam T - The nullable GraphQL type wrapped by this non-null type.
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* const RowType = new GraphQLObjectType({
|
|
1434
|
+
* name: 'Row',
|
|
1435
|
+
* fields: () => ({
|
|
1436
|
+
* id: { type: new GraphQLNonNull(GraphQLString) },
|
|
1437
|
+
* }),
|
|
1438
|
+
* });
|
|
1439
|
+
* ```
|
|
1440
|
+
*
|
|
1441
|
+
* Note: the enforcement of non-nullability occurs within the executor.
|
|
1442
|
+
*/
|
|
1443
|
+
declare class GraphQLNonNull<T extends GraphQLNullableType> implements GraphQLSchemaElement {
|
|
1444
|
+
/** The type wrapped by this list or non-null type. */
|
|
1445
|
+
readonly ofType: T;
|
|
1446
|
+
private readonly __GraphQLNonNullTypeBrand;
|
|
1447
|
+
/**
|
|
1448
|
+
* Creates a GraphQLNonNull instance.
|
|
1449
|
+
* @param ofType - The type to wrap.
|
|
1450
|
+
* @example
|
|
1451
|
+
* ```ts
|
|
1452
|
+
* import { GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1453
|
+
*
|
|
1454
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1455
|
+
*
|
|
1456
|
+
* requiredString.ofType; // => GraphQLString
|
|
1457
|
+
* String(requiredString); // => 'String!'
|
|
1458
|
+
* ```
|
|
1459
|
+
*/
|
|
1460
|
+
constructor(ofType: T);
|
|
1461
|
+
/**
|
|
1462
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1463
|
+
* @returns The built-in string tag for this object.
|
|
1464
|
+
*/
|
|
1465
|
+
get [Symbol.toStringTag](): string;
|
|
1466
|
+
/**
|
|
1467
|
+
* Returns this wrapping type as a GraphQL type-reference string.
|
|
1468
|
+
* @returns The GraphQL type-reference string.
|
|
1469
|
+
* @example
|
|
1470
|
+
* ```ts
|
|
1471
|
+
* import { GraphQLList, GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1472
|
+
*
|
|
1473
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1474
|
+
* const requiredStringList = new GraphQLNonNull(new GraphQLList(GraphQLString));
|
|
1475
|
+
*
|
|
1476
|
+
* requiredString.toString(); // => 'String!'
|
|
1477
|
+
* requiredStringList.toString(); // => '[String]!'
|
|
1478
|
+
* ```
|
|
1479
|
+
*/
|
|
1480
|
+
toString(): string;
|
|
1481
|
+
/**
|
|
1482
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1483
|
+
* @returns The JSON-serializable representation.
|
|
1484
|
+
* @example
|
|
1485
|
+
* ```ts
|
|
1486
|
+
* import { GraphQLNonNull, GraphQLString } from 'graphql/type';
|
|
1487
|
+
*
|
|
1488
|
+
* const requiredString = new GraphQLNonNull(GraphQLString);
|
|
1489
|
+
*
|
|
1490
|
+
* requiredString.toJSON(); // => 'String!'
|
|
1491
|
+
* JSON.stringify({ type: requiredString }); // => '{"type":"String!"}'
|
|
1492
|
+
* ```
|
|
1493
|
+
*/
|
|
1494
|
+
toJSON(): string;
|
|
1495
|
+
}
|
|
1496
|
+
/** These types wrap and modify other types */
|
|
1497
|
+
type GraphQLWrappingType = GraphQLList<GraphQLType> | GraphQLNonNull<GraphQLNullableType>;
|
|
1498
|
+
/** These types can all accept null as a value. */
|
|
1499
|
+
type GraphQLNullableType = GraphQLNamedType | GraphQLList<GraphQLType>;
|
|
1500
|
+
/** These named types do not include modifiers like List or NonNull. */
|
|
1501
|
+
type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;
|
|
1502
|
+
/** A named GraphQL type that can be used as an input type. */
|
|
1503
|
+
type GraphQLNamedInputType = GraphQLScalarType | GraphQLEnumType | GraphQLInputObjectType;
|
|
1504
|
+
/** A named GraphQL type that can be used as an output type. */
|
|
1505
|
+
type GraphQLNamedOutputType = GraphQLScalarType | GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | GraphQLEnumType;
|
|
1506
|
+
/**
|
|
1507
|
+
* An interface for all Schema Elements.
|
|
1508
|
+
*
|
|
1509
|
+
* @internal
|
|
1510
|
+
*/
|
|
1511
|
+
interface GraphQLSchemaElement {
|
|
1512
|
+
toString: () => string;
|
|
1513
|
+
toJSON: () => string;
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Used while defining GraphQL types to allow for circular references in
|
|
1517
|
+
* otherwise immutable type definitions.
|
|
1518
|
+
* @typeParam T - The element type returned by the thunk or array.
|
|
1519
|
+
*/
|
|
1520
|
+
type ThunkReadonlyArray<T> = (() => ReadonlyArray<T>) | ReadonlyArray<T>;
|
|
1521
|
+
/**
|
|
1522
|
+
* A thunk that resolves to an object map.
|
|
1523
|
+
* @typeParam T - Value type stored in the object map.
|
|
1524
|
+
*/
|
|
1525
|
+
type ThunkObjMap<T> = (() => ObjMap<T>) | ObjMap<T>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Custom extensions
|
|
1528
|
+
* @remarks
|
|
1529
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
1530
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
1531
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
1532
|
+
* an object which can contain all the values you need.
|
|
1533
|
+
*/
|
|
1534
|
+
interface GraphQLScalarTypeExtensions {
|
|
1535
|
+
[attributeName: string | symbol]: unknown;
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Scalar Type Definition
|
|
1539
|
+
*
|
|
1540
|
+
* Scalar types define the leaf values of a GraphQL response and the input
|
|
1541
|
+
* values accepted by arguments and input object fields. A scalar type has a
|
|
1542
|
+
* name and coercion functions that validate and convert runtime values and
|
|
1543
|
+
* GraphQL literals.
|
|
1544
|
+
*
|
|
1545
|
+
* If a type's coerceOutputValue function returns `null` or does not return a
|
|
1546
|
+
* value (i.e. it returns `undefined`) then an error will be raised and a
|
|
1547
|
+
* `null` value will be returned in the response. Prefer validating inputs
|
|
1548
|
+
* before execution so clients receive input diagnostics before result coercion
|
|
1549
|
+
* fails.
|
|
1550
|
+
* Custom scalar behavior is defined via the following functions:
|
|
1551
|
+
*
|
|
1552
|
+
* - coerceOutputValue(value): Implements "Result Coercion". Given an internal value,
|
|
1553
|
+
* produces an external value valid for this type. Returns undefined or
|
|
1554
|
+
* throws an error to indicate invalid values.
|
|
1555
|
+
*
|
|
1556
|
+
* - coerceInputValue(value): Implements "Input Coercion" for values. Given an
|
|
1557
|
+
* external value (for example, variable values), produces an internal value
|
|
1558
|
+
* valid for this type. Returns undefined or throws an error to indicate
|
|
1559
|
+
* invalid values.
|
|
1560
|
+
*
|
|
1561
|
+
* - coerceInputLiteral(ast): Implements "Input Coercion" for constant literals.
|
|
1562
|
+
* Given a GraphQL literal (AST) (for example, an argument value), produces
|
|
1563
|
+
* an internal value valid for this type. Returns undefined or throws an
|
|
1564
|
+
* error to indicate invalid values.
|
|
1565
|
+
*
|
|
1566
|
+
* - valueToLiteral(value): Converts an external value to a GraphQL
|
|
1567
|
+
* literal (AST). Returns undefined or throws an error to indicate
|
|
1568
|
+
* invalid values.
|
|
1569
|
+
*
|
|
1570
|
+
* Deprecated, to be removed in v18:
|
|
1571
|
+
*
|
|
1572
|
+
* - serialize(value): Implements "Result Coercion". Renamed to
|
|
1573
|
+
* `coerceOutputValue()`.
|
|
1574
|
+
*
|
|
1575
|
+
* - parseValue(value): Implements "Input Coercion" for values. Renamed to
|
|
1576
|
+
* `coerceInputValue()`.
|
|
1577
|
+
*
|
|
1578
|
+
* - parseLiteral(ast): Implements "Input Coercion" for literals including
|
|
1579
|
+
* non-specified replacement of variables embedded within complex scalars.
|
|
1580
|
+
* Replaced by the combination of the `replaceVariables()` utility and the
|
|
1581
|
+
* `coerceInputLiteral()` method.
|
|
1582
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1583
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1584
|
+
* @example
|
|
1585
|
+
* ```ts
|
|
1586
|
+
* import { GraphQLScalarType, Kind } from 'graphql';
|
|
1587
|
+
*
|
|
1588
|
+
* const ensureOdd = (value) => {
|
|
1589
|
+
* if (!Number.isFinite(value)) {
|
|
1590
|
+
* throw new Error(
|
|
1591
|
+
* `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
|
|
1592
|
+
* );
|
|
1593
|
+
* }
|
|
1594
|
+
*
|
|
1595
|
+
* if (value % 2 === 0) {
|
|
1596
|
+
* throw new Error(
|
|
1597
|
+
* `Scalar "Odd" cannot represent "${value}" since it is even.`,
|
|
1598
|
+
* );
|
|
1599
|
+
* }
|
|
1600
|
+
*
|
|
1601
|
+
* return value;
|
|
1602
|
+
* };
|
|
1603
|
+
*
|
|
1604
|
+
* const OddType = new GraphQLScalarType({
|
|
1605
|
+
* name: 'Odd',
|
|
1606
|
+
* coerceOutputValue: (value) => {
|
|
1607
|
+
* return ensureOdd(value);
|
|
1608
|
+
* },
|
|
1609
|
+
* coerceInputValue: (value) => {
|
|
1610
|
+
* return ensureOdd(value);
|
|
1611
|
+
* },
|
|
1612
|
+
* valueToLiteral: (value) => {
|
|
1613
|
+
* return { kind: Kind.INT, value: String(ensureOdd(value)) };
|
|
1614
|
+
* },
|
|
1615
|
+
* });
|
|
1616
|
+
* ```
|
|
1617
|
+
*/
|
|
1618
|
+
declare class GraphQLScalarType<TInternal = unknown, TExternal = TInternal> implements GraphQLSchemaElement {
|
|
1619
|
+
/** The GraphQL name for this schema element. */
|
|
1620
|
+
name: string;
|
|
1621
|
+
/** Human-readable description for this schema element, if provided. */
|
|
1622
|
+
description: Maybe<string>;
|
|
1623
|
+
/** URL identifying the behavior specified for this custom scalar. */
|
|
1624
|
+
specifiedByURL: Maybe<string>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Deprecated legacy serializer used to convert internal values for response
|
|
1627
|
+
* output. Use `coerceOutputValue()` instead.
|
|
1628
|
+
* @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18
|
|
1629
|
+
*/
|
|
1630
|
+
serialize: GraphQLScalarSerializer<TExternal>;
|
|
1631
|
+
/**
|
|
1632
|
+
* Deprecated legacy parser used to convert externally provided input values.
|
|
1633
|
+
* Use `coerceInputValue()` instead.
|
|
1634
|
+
* @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18
|
|
1635
|
+
*/
|
|
1636
|
+
parseValue: GraphQLScalarValueParser<TInternal>;
|
|
1637
|
+
/**
|
|
1638
|
+
* Deprecated legacy parser used to convert externally provided input
|
|
1639
|
+
* literals. Use `replaceVariables()` and `coerceInputLiteral()` instead.
|
|
1640
|
+
* @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18
|
|
1641
|
+
*/
|
|
1642
|
+
parseLiteral: GraphQLScalarLiteralParser<TInternal>;
|
|
1643
|
+
/** Coercer used to convert internal scalar values for response output. */
|
|
1644
|
+
coerceOutputValue: GraphQLScalarOutputValueCoercer<TExternal>;
|
|
1645
|
+
/** Coercer used to convert externally provided scalar input values. */
|
|
1646
|
+
coerceInputValue: GraphQLScalarInputValueCoercer<TInternal>;
|
|
1647
|
+
/** Coercer used to convert GraphQL scalar input literals. */
|
|
1648
|
+
coerceInputLiteral: GraphQLScalarInputLiteralCoercer<TInternal> | undefined;
|
|
1649
|
+
/** Converter used to produce GraphQL literals from runtime input values. */
|
|
1650
|
+
valueToLiteral: GraphQLScalarValueToLiteral | undefined;
|
|
1651
|
+
/** Custom extension fields reserved for users. */
|
|
1652
|
+
extensions: Readonly<GraphQLScalarTypeExtensions>;
|
|
1653
|
+
/** AST node from which this schema element was built, if available. */
|
|
1654
|
+
astNode: Maybe<ScalarTypeDefinitionNode>;
|
|
1655
|
+
/** AST extension nodes applied to this schema element. */
|
|
1656
|
+
extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
|
|
1657
|
+
/**
|
|
1658
|
+
* Creates a GraphQLScalarType instance.
|
|
1659
|
+
* @param config - Configuration describing this object.
|
|
1660
|
+
* @example
|
|
1661
|
+
* ```ts
|
|
1662
|
+
* import { Kind, parse } from 'graphql/language';
|
|
1663
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1664
|
+
*
|
|
1665
|
+
* const document = parse(`
|
|
1666
|
+
* "Odd integer values."
|
|
1667
|
+
* scalar Odd @specifiedBy(url: "https://example.com/odd")
|
|
1668
|
+
*
|
|
1669
|
+
* extend scalar Odd @specifiedBy(url: "https://example.com/odd-v2")
|
|
1670
|
+
* `);
|
|
1671
|
+
*
|
|
1672
|
+
* const Odd = new GraphQLScalarType({
|
|
1673
|
+
* name: 'Odd',
|
|
1674
|
+
* description: 'Odd integer values.',
|
|
1675
|
+
* specifiedByURL: 'https://example.com/odd',
|
|
1676
|
+
* coerceOutputValue: (value) => {
|
|
1677
|
+
* if (typeof value !== 'number' || value % 2 === 0) {
|
|
1678
|
+
* throw new TypeError('Odd can only produce odd numbers.');
|
|
1679
|
+
* }
|
|
1680
|
+
* return value;
|
|
1681
|
+
* },
|
|
1682
|
+
* coerceInputValue: (value) => {
|
|
1683
|
+
* if (typeof value !== 'number' || value % 2 === 0) {
|
|
1684
|
+
* throw new TypeError('Odd can only accept odd numbers.');
|
|
1685
|
+
* }
|
|
1686
|
+
* return value;
|
|
1687
|
+
* },
|
|
1688
|
+
* coerceInputLiteral: (ast) => {
|
|
1689
|
+
* if (ast.kind !== Kind.INT) {
|
|
1690
|
+
* throw new TypeError('Odd can only accept integer literals.');
|
|
1691
|
+
* }
|
|
1692
|
+
* const value = Number(ast.value);
|
|
1693
|
+
* if (value % 2 === 0) {
|
|
1694
|
+
* throw new TypeError('Odd can only accept odd integer literals.');
|
|
1695
|
+
* }
|
|
1696
|
+
* return value;
|
|
1697
|
+
* },
|
|
1698
|
+
* valueToLiteral: (value) => {
|
|
1699
|
+
* return { kind: Kind.INT, value: String(ensureOdd(value)) };
|
|
1700
|
+
* },
|
|
1701
|
+
* extensions: { numeric: true },
|
|
1702
|
+
* astNode: document.definitions[0],
|
|
1703
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
1704
|
+
* });
|
|
1705
|
+
*
|
|
1706
|
+
* Odd.description; // => 'Odd integer values.'
|
|
1707
|
+
* Odd.specifiedByURL; // => 'https://example.com/odd'
|
|
1708
|
+
* Odd.coerceOutputValue(3); // => 3
|
|
1709
|
+
* Odd.coerceInputValue(5); // => 5
|
|
1710
|
+
* Odd.extensions; // => { numeric: true }
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
constructor(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>);
|
|
1714
|
+
/**
|
|
1715
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
1716
|
+
* @returns The built-in string tag for this object.
|
|
1717
|
+
*/
|
|
1718
|
+
get [Symbol.toStringTag](): string;
|
|
1719
|
+
/**
|
|
1720
|
+
* Returns a normalized configuration object for this object.
|
|
1721
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
1722
|
+
* @example
|
|
1723
|
+
* ```ts
|
|
1724
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1725
|
+
*
|
|
1726
|
+
* const Url = new GraphQLScalarType({
|
|
1727
|
+
* name: 'Url',
|
|
1728
|
+
* description: 'An absolute URL string.',
|
|
1729
|
+
* specifiedByURL: 'https://url.spec.whatwg.org/',
|
|
1730
|
+
* });
|
|
1731
|
+
*
|
|
1732
|
+
* const config = Url.toConfig();
|
|
1733
|
+
* const UrlCopy = new GraphQLScalarType(config);
|
|
1734
|
+
*
|
|
1735
|
+
* config.name; // => 'Url'
|
|
1736
|
+
* config.specifiedByURL; // => 'https://url.spec.whatwg.org/'
|
|
1737
|
+
* UrlCopy.name; // => Url.name
|
|
1738
|
+
* ```
|
|
1739
|
+
*/
|
|
1740
|
+
toConfig(): GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>;
|
|
1741
|
+
/**
|
|
1742
|
+
* Returns the schema coordinate identifying this scalar type.
|
|
1743
|
+
* @returns The schema coordinate for this scalar type.
|
|
1744
|
+
* @example
|
|
1745
|
+
* ```ts
|
|
1746
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1747
|
+
*
|
|
1748
|
+
* const DateTime = new GraphQLScalarType({ name: 'DateTime' });
|
|
1749
|
+
*
|
|
1750
|
+
* DateTime.toString(); // => 'DateTime'
|
|
1751
|
+
* String(DateTime); // => 'DateTime'
|
|
1752
|
+
* ```
|
|
1753
|
+
*/
|
|
1754
|
+
toString(): string;
|
|
1755
|
+
/**
|
|
1756
|
+
* Returns the JSON representation used when this object is serialized.
|
|
1757
|
+
* @returns The JSON-serializable representation.
|
|
1758
|
+
* @example
|
|
1759
|
+
* ```ts
|
|
1760
|
+
* import { GraphQLScalarType } from 'graphql/type';
|
|
1761
|
+
*
|
|
1762
|
+
* const DateTime = new GraphQLScalarType({ name: 'DateTime' });
|
|
1763
|
+
*
|
|
1764
|
+
* DateTime.toJSON(); // => 'DateTime'
|
|
1765
|
+
* JSON.stringify({ type: DateTime }); // => '{"type":"DateTime"}'
|
|
1766
|
+
* ```
|
|
1767
|
+
*/
|
|
1768
|
+
toJSON(): string;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Deprecated function type that serializes a runtime value as a scalar output
|
|
1772
|
+
* value. Use `GraphQLScalarOutputValueCoercer` instead.
|
|
1773
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1774
|
+
* @deprecated Use GraphQLScalarOutputValueCoercer instead. Will be removed in v18.
|
|
1775
|
+
*/
|
|
1776
|
+
type GraphQLScalarSerializer<TExternal> = (outputValue: unknown) => TExternal;
|
|
1777
|
+
/**
|
|
1778
|
+
* Function used to coerce internal scalar values for response output.
|
|
1779
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1780
|
+
*/
|
|
1781
|
+
type GraphQLScalarOutputValueCoercer<TExternal> = (outputValue: unknown) => TExternal;
|
|
1782
|
+
/**
|
|
1783
|
+
* Deprecated function type that parses a runtime input value as a scalar input
|
|
1784
|
+
* value. Use `GraphQLScalarInputValueCoercer` instead.
|
|
1785
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1786
|
+
* @deprecated Use GraphQLScalarInputValueCoercer instead. Will be removed in v18.
|
|
1787
|
+
*/
|
|
1788
|
+
type GraphQLScalarValueParser<TInternal> = (inputValue: unknown) => TInternal;
|
|
1789
|
+
/**
|
|
1790
|
+
* Function used to coerce externally provided scalar input values.
|
|
1791
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1792
|
+
*/
|
|
1793
|
+
type GraphQLScalarInputValueCoercer<TInternal> = (inputValue: unknown) => TInternal;
|
|
1794
|
+
/**
|
|
1795
|
+
* Deprecated function type that parses a GraphQL value literal as a scalar
|
|
1796
|
+
* input value. Use `GraphQLScalarInputLiteralCoercer` instead.
|
|
1797
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1798
|
+
* @deprecated Use GraphQLScalarInputLiteralCoercer instead. Will be removed in v18.
|
|
1799
|
+
*/
|
|
1800
|
+
type GraphQLScalarLiteralParser<TInternal> = (valueNode: ValueNode, variables: Maybe<ObjMap<unknown>>) => Maybe<TInternal>;
|
|
1801
|
+
/**
|
|
1802
|
+
* Function used to coerce GraphQL scalar input literals.
|
|
1803
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1804
|
+
*/
|
|
1805
|
+
type GraphQLScalarInputLiteralCoercer<TInternal> = (valueNode: ConstValueNode) => Maybe<TInternal>;
|
|
1806
|
+
/** @internal */
|
|
1807
|
+
type GraphQLScalarValueToLiteral = (inputValue: unknown) => ConstValueNode | undefined;
|
|
1808
|
+
/**
|
|
1809
|
+
* Configuration used to construct a GraphQLScalarType.
|
|
1810
|
+
* @typeParam TInternal - Internal runtime representation for this scalar.
|
|
1811
|
+
* @typeParam TExternal - External representation accepted from or returned to callers.
|
|
1812
|
+
*/
|
|
1813
|
+
interface GraphQLScalarTypeConfig<TInternal, TExternal> {
|
|
1814
|
+
/** The GraphQL name for this schema element. */
|
|
1815
|
+
name: string;
|
|
1816
|
+
/** Human-readable description for this schema element, if provided. */
|
|
1817
|
+
description?: Maybe<string>;
|
|
1818
|
+
/** URL identifying the behavior specified for this custom scalar. */
|
|
1819
|
+
specifiedByURL?: Maybe<string>;
|
|
1820
|
+
/**
|
|
1821
|
+
* Deprecated legacy serializer used to convert internal values for response
|
|
1822
|
+
* output. Use `coerceOutputValue()` instead.
|
|
1823
|
+
* @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18
|
|
1824
|
+
*/
|
|
1825
|
+
serialize?: GraphQLScalarSerializer<TExternal> | undefined;
|
|
1826
|
+
/**
|
|
1827
|
+
* Deprecated legacy parser used to convert externally provided input values.
|
|
1828
|
+
* Use `coerceInputValue()` instead.
|
|
1829
|
+
* @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18
|
|
1830
|
+
*/
|
|
1831
|
+
parseValue?: GraphQLScalarValueParser<TInternal> | undefined;
|
|
1832
|
+
/**
|
|
1833
|
+
* Deprecated legacy parser used to convert externally provided input
|
|
1834
|
+
* literals. Use `replaceVariables()` and `coerceInputLiteral()` instead.
|
|
1835
|
+
* @deprecated use `replaceVariables()` and `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18
|
|
1836
|
+
*/
|
|
1837
|
+
parseLiteral?: GraphQLScalarLiteralParser<TInternal> | undefined;
|
|
1838
|
+
/** Coerces an internal value to include in a response. */
|
|
1839
|
+
coerceOutputValue?: GraphQLScalarOutputValueCoercer<TExternal> | undefined;
|
|
1840
|
+
/** Coerces an externally provided value to use as an input. */
|
|
1841
|
+
coerceInputValue?: GraphQLScalarInputValueCoercer<TInternal> | undefined;
|
|
1842
|
+
/** Coerces an externally provided const literal value to use as an input. */
|
|
1843
|
+
coerceInputLiteral?: GraphQLScalarInputLiteralCoercer<TInternal> | undefined;
|
|
1844
|
+
/** Translates an externally provided value to a literal (AST). */
|
|
1845
|
+
valueToLiteral?: GraphQLScalarValueToLiteral | undefined;
|
|
1846
|
+
/** Custom extension fields reserved for users. */
|
|
1847
|
+
extensions?: Maybe<Readonly<GraphQLScalarTypeExtensions>>;
|
|
1848
|
+
/** AST node from which this schema element was built, if available. */
|
|
1849
|
+
astNode?: Maybe<ScalarTypeDefinitionNode>;
|
|
1850
|
+
/** AST extension nodes applied to this schema element. */
|
|
1851
|
+
extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
|
|
1852
|
+
}
|
|
1853
|
+
/** @internal */
|
|
1854
|
+
interface GraphQLScalarTypeNormalizedConfig<TInternal, TExternal> extends GraphQLScalarTypeConfig<TInternal, TExternal> {
|
|
1855
|
+
serialize: GraphQLScalarSerializer<TExternal>;
|
|
1856
|
+
parseValue: GraphQLScalarValueParser<TInternal>;
|
|
1857
|
+
parseLiteral: GraphQLScalarLiteralParser<TInternal>;
|
|
1858
|
+
coerceOutputValue: GraphQLScalarOutputValueCoercer<TExternal>;
|
|
1859
|
+
coerceInputValue: GraphQLScalarInputValueCoercer<TInternal>;
|
|
1860
|
+
coerceInputLiteral: GraphQLScalarInputLiteralCoercer<TInternal> | undefined;
|
|
1861
|
+
extensions: Readonly<GraphQLScalarTypeExtensions>;
|
|
1862
|
+
extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Custom extensions
|
|
1866
|
+
* @remarks
|
|
1867
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
1868
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
1869
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
1870
|
+
* an object which can contain all the values you need.
|
|
1871
|
+
* We've provided these template arguments because this is an open type and
|
|
1872
|
+
* you may find them useful.
|
|
1873
|
+
* @typeParam _TSource - Reserved source type parameter for extension typing.
|
|
1874
|
+
* @typeParam _TContext - Reserved context type parameter for extension typing.
|
|
1875
|
+
*/
|
|
1876
|
+
interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
|
|
1877
|
+
[attributeName: string | symbol]: unknown;
|
|
1878
|
+
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Object Type Definition
|
|
1881
|
+
*
|
|
1882
|
+
* Almost all of the GraphQL types you define will be object types. Object types
|
|
1883
|
+
* have a name, but most importantly describe their fields.
|
|
1884
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
1885
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
1886
|
+
* @typeParam TAbstract - Runtime value type used for abstract type resolution.
|
|
1887
|
+
* @example
|
|
1888
|
+
* ```ts
|
|
1889
|
+
* const AddressType = new GraphQLObjectType({
|
|
1890
|
+
* name: 'Address',
|
|
1891
|
+
* fields: {
|
|
1892
|
+
* street: { type: GraphQLString },
|
|
1893
|
+
* number: { type: GraphQLInt },
|
|
1894
|
+
* formatted: {
|
|
1895
|
+
* type: GraphQLString,
|
|
1896
|
+
* resolve: (obj) => {
|
|
1897
|
+
* return obj.number + ' ' + obj.street;
|
|
1898
|
+
* },
|
|
1899
|
+
* },
|
|
1900
|
+
* },
|
|
1901
|
+
* });
|
|
1902
|
+
* ```
|
|
1903
|
+
* @example
|
|
1904
|
+
* When two types need to refer to each other, or a type needs to refer to
|
|
1905
|
+
* itself in a field, you can use a function expression (aka a closure or a
|
|
1906
|
+
* thunk) to supply the fields lazily.
|
|
1907
|
+
*
|
|
1908
|
+
* ```ts
|
|
1909
|
+
* const PersonType = new GraphQLObjectType({
|
|
1910
|
+
* name: 'Person',
|
|
1911
|
+
* fields: () => ({
|
|
1912
|
+
* name: { type: GraphQLString },
|
|
1913
|
+
* bestFriend: { type: PersonType },
|
|
1914
|
+
* }),
|
|
1915
|
+
* });
|
|
1916
|
+
* ```
|
|
1917
|
+
*/
|
|
1918
|
+
declare class GraphQLObjectType<TSource = any, TContext = any, TAbstract = any> implements GraphQLSchemaElement {
|
|
1919
|
+
/** The GraphQL name for this schema element. */
|
|
1920
|
+
name: string;
|
|
1921
|
+
/** Human-readable description for this schema element, if provided. */
|
|
1922
|
+
description: Maybe<string>;
|
|
1923
|
+
/** Predicate used to determine whether a runtime value belongs to this object type. */
|
|
1924
|
+
isTypeOf: Maybe<GraphQLIsTypeOfFn<TAbstract, TContext>>;
|
|
1925
|
+
/** Custom extension fields reserved for users. */
|
|
1926
|
+
extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
|
|
1927
|
+
/** AST node from which this schema element was built, if available. */
|
|
1928
|
+
astNode: Maybe<ObjectTypeDefinitionNode>;
|
|
1929
|
+
/** AST extension nodes applied to this schema element. */
|
|
1930
|
+
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
|
|
1931
|
+
private _fields;
|
|
1932
|
+
private _interfaces;
|
|
1933
|
+
/**
|
|
1934
|
+
* Creates a GraphQLObjectType instance.
|
|
1935
|
+
* @param config - Configuration describing this object.
|
|
1936
|
+
* @example
|
|
1937
|
+
* ```ts
|
|
1938
|
+
* // Configure an object type with interfaces, fields, arguments, and metadata.
|
|
1939
|
+
* import { parse } from 'graphql/language';
|
|
1940
|
+
* import {
|
|
1941
|
+
* GraphQLID,
|
|
1942
|
+
* GraphQLInterfaceType,
|
|
1943
|
+
* GraphQLNonNull,
|
|
1944
|
+
* GraphQLObjectType,
|
|
1945
|
+
* GraphQLString,
|
|
1946
|
+
* } from 'graphql/type';
|
|
1947
|
+
*
|
|
1948
|
+
* const document = parse(`
|
|
1949
|
+
* type User implements Node {
|
|
1950
|
+
* id: ID!
|
|
1951
|
+
* name(format: String = "short"): String
|
|
1952
|
+
* }
|
|
1953
|
+
*
|
|
1954
|
+
* extend type User {
|
|
1955
|
+
* displayName: String
|
|
1956
|
+
* }
|
|
1957
|
+
* `);
|
|
1958
|
+
* const definition = document.definitions[0];
|
|
1959
|
+
* const nameField = definition.fields[1];
|
|
1960
|
+
* const formatArg = nameField.arguments[0];
|
|
1961
|
+
*
|
|
1962
|
+
* const Node = new GraphQLInterfaceType({
|
|
1963
|
+
* name: 'Node',
|
|
1964
|
+
* fields: {
|
|
1965
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
1966
|
+
* },
|
|
1967
|
+
* });
|
|
1968
|
+
*
|
|
1969
|
+
* const User = new GraphQLObjectType({
|
|
1970
|
+
* name: 'User',
|
|
1971
|
+
* description: 'A registered user.',
|
|
1972
|
+
* interfaces: [Node],
|
|
1973
|
+
* fields: {
|
|
1974
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
1975
|
+
* name: {
|
|
1976
|
+
* description: 'The formatted user name.',
|
|
1977
|
+
* type: GraphQLString,
|
|
1978
|
+
* args: {
|
|
1979
|
+
* format: {
|
|
1980
|
+
* description: 'Controls the name format.',
|
|
1981
|
+
* type: GraphQLString,
|
|
1982
|
+
* default: { value: 'short' },
|
|
1983
|
+
* deprecationReason: 'Use locale instead.',
|
|
1984
|
+
* extensions: { public: true },
|
|
1985
|
+
* astNode: formatArg,
|
|
1986
|
+
* },
|
|
1987
|
+
* },
|
|
1988
|
+
* resolve: (user, { format }) => {
|
|
1989
|
+
* return format === 'long' ? user.fullName : user.name;
|
|
1990
|
+
* },
|
|
1991
|
+
* deprecationReason: 'Use displayName.',
|
|
1992
|
+
* extensions: { cacheSeconds: 60 },
|
|
1993
|
+
* astNode: nameField,
|
|
1994
|
+
* },
|
|
1995
|
+
* },
|
|
1996
|
+
* isTypeOf: (value) => {
|
|
1997
|
+
* return typeof value === 'object' && value != null && 'id' in value;
|
|
1998
|
+
* },
|
|
1999
|
+
* extensions: { entity: 'User' },
|
|
2000
|
+
* astNode: definition,
|
|
2001
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
2002
|
+
* });
|
|
2003
|
+
*
|
|
2004
|
+
* User.name; // => 'User'
|
|
2005
|
+
* User.getInterfaces(); // => [Node]
|
|
2006
|
+
* Object.keys(User.getFields()); // => ['id', 'name']
|
|
2007
|
+
* User.getFields().name.args[0].default.value; // => 'short'
|
|
2008
|
+
* User.extensions; // => { entity: 'User' }
|
|
2009
|
+
* ```
|
|
2010
|
+
* @example
|
|
2011
|
+
* ```ts
|
|
2012
|
+
* // This variant configures a subscription field with subscribe and resolve functions.
|
|
2013
|
+
* import { GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2014
|
+
*
|
|
2015
|
+
* const Subscription = new GraphQLObjectType({
|
|
2016
|
+
* name: 'Subscription',
|
|
2017
|
+
* fields: {
|
|
2018
|
+
* greeting: {
|
|
2019
|
+
* type: GraphQLString,
|
|
2020
|
+
* subscribe: async function* () {
|
|
2021
|
+
* yield { greeting: 'Hello!' };
|
|
2022
|
+
* },
|
|
2023
|
+
* resolve: (event) => {
|
|
2024
|
+
* return event.greeting;
|
|
2025
|
+
* },
|
|
2026
|
+
* },
|
|
2027
|
+
* },
|
|
2028
|
+
* });
|
|
2029
|
+
*
|
|
2030
|
+
* typeof Subscription.getFields().greeting.subscribe; // => 'function'
|
|
2031
|
+
* ```
|
|
2032
|
+
*/
|
|
2033
|
+
constructor(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext, TAbstract>>);
|
|
2034
|
+
/**
|
|
2035
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2036
|
+
* @returns The built-in string tag for this object.
|
|
2037
|
+
*/
|
|
2038
|
+
get [Symbol.toStringTag](): string;
|
|
2039
|
+
/**
|
|
2040
|
+
* Returns the fields defined by this type.
|
|
2041
|
+
* @returns The fields keyed by field name.
|
|
2042
|
+
* @example
|
|
2043
|
+
* ```ts
|
|
2044
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2045
|
+
* import { assertObjectType } from 'graphql/type';
|
|
2046
|
+
*
|
|
2047
|
+
* const schema = buildSchema(`
|
|
2048
|
+
* type User {
|
|
2049
|
+
* id: ID!
|
|
2050
|
+
* name: String
|
|
2051
|
+
* }
|
|
2052
|
+
*
|
|
2053
|
+
* type Query {
|
|
2054
|
+
* viewer: User
|
|
2055
|
+
* }
|
|
2056
|
+
* `);
|
|
2057
|
+
*
|
|
2058
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
2059
|
+
* const fields = User.getFields();
|
|
2060
|
+
*
|
|
2061
|
+
* Object.keys(fields); // => ['id', 'name']
|
|
2062
|
+
* String(fields.id.type); // => 'ID!'
|
|
2063
|
+
* ```
|
|
2064
|
+
*/
|
|
2065
|
+
getFields(): GraphQLFieldMap<TSource, TContext>;
|
|
2066
|
+
/**
|
|
2067
|
+
* Returns the interfaces implemented by this type.
|
|
2068
|
+
* @returns The implemented interfaces.
|
|
2069
|
+
* @example
|
|
2070
|
+
* ```ts
|
|
2071
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2072
|
+
* import { assertObjectType } from 'graphql/type';
|
|
2073
|
+
*
|
|
2074
|
+
* const schema = buildSchema(`
|
|
2075
|
+
* interface Node {
|
|
2076
|
+
* id: ID!
|
|
2077
|
+
* }
|
|
2078
|
+
*
|
|
2079
|
+
* type User implements Node {
|
|
2080
|
+
* id: ID!
|
|
2081
|
+
* }
|
|
2082
|
+
*
|
|
2083
|
+
* type Query {
|
|
2084
|
+
* viewer: User
|
|
2085
|
+
* }
|
|
2086
|
+
* `);
|
|
2087
|
+
*
|
|
2088
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
2089
|
+
*
|
|
2090
|
+
* User.getInterfaces().map((type) => type.name); // => ['Node']
|
|
2091
|
+
* ```
|
|
2092
|
+
*/
|
|
2093
|
+
getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
|
|
2094
|
+
/**
|
|
2095
|
+
* Returns a normalized configuration object for this object.
|
|
2096
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
2097
|
+
* @example
|
|
2098
|
+
* ```ts
|
|
2099
|
+
* import { GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2100
|
+
*
|
|
2101
|
+
* const User = new GraphQLObjectType({
|
|
2102
|
+
* name: 'User',
|
|
2103
|
+
* fields: {
|
|
2104
|
+
* name: { type: GraphQLString },
|
|
2105
|
+
* },
|
|
2106
|
+
* });
|
|
2107
|
+
*
|
|
2108
|
+
* const config = User.toConfig();
|
|
2109
|
+
* const UserCopy = new GraphQLObjectType(config);
|
|
2110
|
+
*
|
|
2111
|
+
* config.fields.name.type; // => GraphQLString
|
|
2112
|
+
* UserCopy.getFields().name.type; // => GraphQLString
|
|
2113
|
+
* ```
|
|
2114
|
+
*/
|
|
2115
|
+
toConfig(): GraphQLObjectTypeNormalizedConfig<TSource, TContext, TAbstract>;
|
|
2116
|
+
/**
|
|
2117
|
+
* Returns the schema coordinate identifying this object type.
|
|
2118
|
+
* @returns The schema coordinate for this object type.
|
|
2119
|
+
* @example
|
|
2120
|
+
* ```ts
|
|
2121
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2122
|
+
* import { assertObjectType } from 'graphql/type';
|
|
2123
|
+
*
|
|
2124
|
+
* const schema = buildSchema(`
|
|
2125
|
+
* type User {
|
|
2126
|
+
* name: String
|
|
2127
|
+
* }
|
|
2128
|
+
*
|
|
2129
|
+
* type Query {
|
|
2130
|
+
* viewer: User
|
|
2131
|
+
* }
|
|
2132
|
+
* `);
|
|
2133
|
+
*
|
|
2134
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
2135
|
+
*
|
|
2136
|
+
* User.toString(); // => 'User'
|
|
2137
|
+
* ```
|
|
2138
|
+
*/
|
|
2139
|
+
toString(): string;
|
|
2140
|
+
/**
|
|
2141
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2142
|
+
* @returns The JSON-serializable representation.
|
|
2143
|
+
* @example
|
|
2144
|
+
* ```ts
|
|
2145
|
+
* import { GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2146
|
+
*
|
|
2147
|
+
* const User = new GraphQLObjectType({
|
|
2148
|
+
* name: 'User',
|
|
2149
|
+
* fields: { name: { type: GraphQLString } },
|
|
2150
|
+
* });
|
|
2151
|
+
*
|
|
2152
|
+
* User.toJSON(); // => 'User'
|
|
2153
|
+
* JSON.stringify({ type: User }); // => '{"type":"User"}'
|
|
2154
|
+
* ```
|
|
2155
|
+
*/
|
|
2156
|
+
toJSON(): string;
|
|
2157
|
+
}
|
|
2158
|
+
/**
|
|
2159
|
+
* Configuration used to construct a GraphQLObjectType.
|
|
2160
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2161
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2162
|
+
* @typeParam TAbstract - Runtime value type used for abstract type resolution.
|
|
2163
|
+
*/
|
|
2164
|
+
interface GraphQLObjectTypeConfig<TSource, TContext, TAbstract = unknown> {
|
|
2165
|
+
/** The GraphQL name for this schema element. */
|
|
2166
|
+
name: string;
|
|
2167
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2168
|
+
description?: Maybe<string>;
|
|
2169
|
+
/** Interfaces implemented by this object or interface type. */
|
|
2170
|
+
interfaces?: ThunkReadonlyArray<GraphQLInterfaceType> | undefined;
|
|
2171
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
2172
|
+
fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
|
|
2173
|
+
/** Predicate used to determine whether a runtime value belongs to this object type. */
|
|
2174
|
+
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TAbstract, TContext>>;
|
|
2175
|
+
/** Custom extension fields reserved for users. */
|
|
2176
|
+
extensions?: Maybe<Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>>;
|
|
2177
|
+
/** AST node from which this schema element was built, if available. */
|
|
2178
|
+
astNode?: Maybe<ObjectTypeDefinitionNode>;
|
|
2179
|
+
/** AST extension nodes applied to this schema element. */
|
|
2180
|
+
extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
|
|
2181
|
+
}
|
|
2182
|
+
/** @internal */
|
|
2183
|
+
interface GraphQLObjectTypeNormalizedConfig<TSource, TContext, TAbstract = unknown> extends GraphQLObjectTypeConfig<TSource, TContext, TAbstract> {
|
|
2184
|
+
interfaces: ReadonlyArray<GraphQLInterfaceType>;
|
|
2185
|
+
fields: GraphQLFieldNormalizedConfigMap<TSource, TContext>;
|
|
2186
|
+
extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
|
|
2187
|
+
extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Resolves the concrete object type for an abstract GraphQL type.
|
|
2191
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2192
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2193
|
+
*/
|
|
2194
|
+
type GraphQLTypeResolver<TSource, TContext> = (value: TSource, context: TContext, info: GraphQLResolveInfo, abstractType: GraphQLAbstractType) => PromiseOrValue<string | undefined>;
|
|
2195
|
+
/**
|
|
2196
|
+
* Checks whether a runtime value belongs to a GraphQL object type.
|
|
2197
|
+
* @typeParam TAbstract - Runtime value type used for abstract type resolution.
|
|
2198
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2199
|
+
*/
|
|
2200
|
+
type GraphQLIsTypeOfFn<TAbstract, TContext> = (value: TAbstract, context: TContext, info: GraphQLResolveInfo) => PromiseOrValue<boolean>;
|
|
2201
|
+
/**
|
|
2202
|
+
* Resolves the runtime value for a GraphQL field.
|
|
2203
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2204
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2205
|
+
* @typeParam TArgs - Argument object type passed to resolvers.
|
|
2206
|
+
* @typeParam TResult - Result value type.
|
|
2207
|
+
*/
|
|
2208
|
+
type GraphQLFieldResolver<TSource, TContext, TArgs = any, TResult = unknown> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TResult;
|
|
2209
|
+
/** Utilities available from resolver info for tracking asynchronous work. */
|
|
2210
|
+
interface GraphQLResolveInfoHelpers {
|
|
2211
|
+
/**
|
|
2212
|
+
* Promise.all wrapper that allows rejected branches to be tracked
|
|
2213
|
+
* as execution async work.
|
|
2214
|
+
*
|
|
2215
|
+
* Intended use: return or await this promise from resolver work.
|
|
2216
|
+
* Un-awaited async side effects are an anti-pattern:
|
|
2217
|
+
*
|
|
2218
|
+
* const { promiseAll } = info.getAsyncHelpers();
|
|
2219
|
+
* promiseAll([someAsyncWork(), someOtherAsyncWork()]).catch(() => undefined);
|
|
2220
|
+
*
|
|
2221
|
+
* In that anti-pattern, tracking starts only after rejection (on a
|
|
2222
|
+
* later microtask), so this work is not guaranteed to delay
|
|
2223
|
+
* `hooks.asyncWorkFinished`.
|
|
2224
|
+
*
|
|
2225
|
+
* Use `track(...)` for un-awaited async side effects:
|
|
2226
|
+
*
|
|
2227
|
+
* const { track } = info.getAsyncHelpers();
|
|
2228
|
+
* track([
|
|
2229
|
+
* someAsyncWork().catch(() => undefined),
|
|
2230
|
+
* someOtherAsyncWork().catch(() => undefined)
|
|
2231
|
+
* ]);
|
|
2232
|
+
*/
|
|
2233
|
+
readonly promiseAll: <T>(values: ReadonlyArray<PromiseLike<T> | T>) => Promise<Array<T>>;
|
|
2234
|
+
/** Tracks asynchronous work that should delay execution completion hooks. */
|
|
2235
|
+
readonly track: (maybePromises: ReadonlyArray<unknown>) => void;
|
|
2236
|
+
}
|
|
2237
|
+
/** Information about the currently executing GraphQL field. */
|
|
2238
|
+
interface GraphQLResolveInfo {
|
|
2239
|
+
/** The field name referenced by this schema coordinate. */
|
|
2240
|
+
readonly fieldName: string;
|
|
2241
|
+
/** AST field nodes that contributed to the current field execution. */
|
|
2242
|
+
readonly fieldNodes: ReadonlyArray<FieldNode>;
|
|
2243
|
+
/** GraphQL output type declared for the current field. */
|
|
2244
|
+
readonly returnType: GraphQLOutputType;
|
|
2245
|
+
/** Object type that owns the current field. */
|
|
2246
|
+
readonly parentType: GraphQLObjectType;
|
|
2247
|
+
/** Response path where this error occurred during execution. */
|
|
2248
|
+
readonly path: Path;
|
|
2249
|
+
/** The schema used for validation or execution. */
|
|
2250
|
+
readonly schema: GraphQLSchema;
|
|
2251
|
+
/** Fragment definitions in the operation document keyed by fragment name. */
|
|
2252
|
+
readonly fragments: ObjMap<FragmentDefinitionNode>;
|
|
2253
|
+
/** Initial root value passed to the operation. */
|
|
2254
|
+
readonly rootValue: unknown;
|
|
2255
|
+
/** The operation selected for execution. */
|
|
2256
|
+
readonly operation: OperationDefinitionNode;
|
|
2257
|
+
/**
|
|
2258
|
+
* Coerced variable values and source metadata for this operation. Resolver
|
|
2259
|
+
* code that needs runtime variable values should read `variableValues.coerced`.
|
|
2260
|
+
*/
|
|
2261
|
+
readonly variableValues: VariableValues;
|
|
2262
|
+
/** Returns the AbortSignal supplied for this execution, if any. */
|
|
2263
|
+
readonly getAbortSignal: () => AbortSignal | undefined;
|
|
2264
|
+
/** Returns helper functions for tracking asynchronous resolver work. */
|
|
2265
|
+
readonly getAsyncHelpers: () => GraphQLResolveInfoHelpers;
|
|
2266
|
+
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Custom extensions
|
|
2269
|
+
* @remarks
|
|
2270
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
2271
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
2272
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
2273
|
+
* an object which can contain all the values you need.
|
|
2274
|
+
* We've provided these template arguments because this is an open type and
|
|
2275
|
+
* you may find them useful.
|
|
2276
|
+
* @typeParam _TSource - Reserved source type parameter for extension typing.
|
|
2277
|
+
* @typeParam _TContext - Reserved context type parameter for extension typing.
|
|
2278
|
+
* @typeParam _TArgs - Reserved argument type parameter for extension typing.
|
|
2279
|
+
*/
|
|
2280
|
+
interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {
|
|
2281
|
+
[attributeName: string | symbol]: unknown;
|
|
2282
|
+
}
|
|
2283
|
+
/**
|
|
2284
|
+
* Configuration used to define a GraphQL field.
|
|
2285
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2286
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2287
|
+
* @typeParam TArgs - Argument object type passed to resolvers.
|
|
2288
|
+
*/
|
|
2289
|
+
interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {
|
|
2290
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2291
|
+
description?: Maybe<string>;
|
|
2292
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
2293
|
+
type: GraphQLOutputType;
|
|
2294
|
+
/** Arguments accepted by this field or directive. */
|
|
2295
|
+
args?: GraphQLFieldConfigArgumentMap | undefined;
|
|
2296
|
+
/** Resolver function used to produce this field value. */
|
|
2297
|
+
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2298
|
+
/** Resolver function used to create a subscription event stream for this field. */
|
|
2299
|
+
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2300
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
2301
|
+
deprecationReason?: Maybe<string>;
|
|
2302
|
+
/** Custom extension fields reserved for users. */
|
|
2303
|
+
extensions?: Maybe<Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>>;
|
|
2304
|
+
/** AST node from which this schema element was built, if available. */
|
|
2305
|
+
astNode?: Maybe<FieldDefinitionNode>;
|
|
2306
|
+
}
|
|
2307
|
+
/** @internal */
|
|
2308
|
+
interface GraphQLFieldNormalizedConfig<TSource, TContext, TArgs = any> extends GraphQLFieldConfig<TSource, TContext, TArgs> {
|
|
2309
|
+
args: GraphQLFieldNormalizedConfigArgumentMap;
|
|
2310
|
+
extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
|
|
2311
|
+
}
|
|
2312
|
+
/** A map of argument names to argument configuration objects. */
|
|
2313
|
+
type GraphQLFieldConfigArgumentMap = ObjMap<GraphQLArgumentConfig>;
|
|
2314
|
+
/** @internal */
|
|
2315
|
+
type GraphQLFieldNormalizedConfigArgumentMap = ObjMap<GraphQLArgumentNormalizedConfig>;
|
|
2316
|
+
/**
|
|
2317
|
+
* Custom extensions
|
|
2318
|
+
* @remarks
|
|
2319
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
2320
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
2321
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
2322
|
+
* an object which can contain all the values you need.
|
|
2323
|
+
*/
|
|
2324
|
+
interface GraphQLArgumentExtensions {
|
|
2325
|
+
[attributeName: string | symbol]: unknown;
|
|
2326
|
+
}
|
|
2327
|
+
/** Configuration used to define a GraphQL argument. */
|
|
2328
|
+
interface GraphQLArgumentConfig {
|
|
2329
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2330
|
+
description?: Maybe<string>;
|
|
2331
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
2332
|
+
type: GraphQLInputType;
|
|
2333
|
+
/**
|
|
2334
|
+
* Deprecated legacy default value for this argument. Use `default` instead.
|
|
2335
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
2336
|
+
*/
|
|
2337
|
+
defaultValue?: unknown;
|
|
2338
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
2339
|
+
default?: GraphQLDefaultInput | undefined;
|
|
2340
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
2341
|
+
deprecationReason?: Maybe<string>;
|
|
2342
|
+
/** Custom extension fields reserved for users. */
|
|
2343
|
+
extensions?: Maybe<Readonly<GraphQLArgumentExtensions>>;
|
|
2344
|
+
/** AST node from which this schema element was built, if available. */
|
|
2345
|
+
astNode?: Maybe<InputValueDefinitionNode>;
|
|
2346
|
+
}
|
|
2347
|
+
/** @internal */
|
|
2348
|
+
interface GraphQLArgumentNormalizedConfig extends GraphQLArgumentConfig {
|
|
2349
|
+
default: GraphQLDefaultInput | undefined;
|
|
2350
|
+
extensions: Readonly<GraphQLArgumentExtensions>;
|
|
2351
|
+
}
|
|
2352
|
+
/** @internal */
|
|
2353
|
+
type GraphQLFieldNormalizedConfigMap<TSource, TContext> = ObjMap<GraphQLFieldNormalizedConfig<TSource, TContext>>;
|
|
2354
|
+
/**
|
|
2355
|
+
* A resolved GraphQL field definition.
|
|
2356
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2357
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2358
|
+
* @typeParam TArgs - Argument object type passed to resolvers.
|
|
2359
|
+
*/
|
|
2360
|
+
declare class GraphQLField<TSource = any, TContext = any, TArgs = any> implements GraphQLSchemaElement {
|
|
2361
|
+
/** Object or interface type that owns this field, if known. */
|
|
2362
|
+
parentType: GraphQLObjectType<TSource, TContext> | GraphQLInterfaceType<TSource, TContext> | undefined;
|
|
2363
|
+
/** The GraphQL name for this schema element. */
|
|
2364
|
+
name: string;
|
|
2365
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2366
|
+
description: Maybe<string>;
|
|
2367
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
2368
|
+
type: GraphQLOutputType;
|
|
2369
|
+
/** Arguments accepted by this field or directive. */
|
|
2370
|
+
args: ReadonlyArray<GraphQLArgument>;
|
|
2371
|
+
/** Resolver function used to produce this field value. */
|
|
2372
|
+
resolve?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2373
|
+
/** Resolver function used to create a subscription event stream for this field. */
|
|
2374
|
+
subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs> | undefined;
|
|
2375
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
2376
|
+
deprecationReason: Maybe<string>;
|
|
2377
|
+
/** Custom extension fields reserved for users. */
|
|
2378
|
+
extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
|
|
2379
|
+
/** AST node from which this schema element was built, if available. */
|
|
2380
|
+
astNode: Maybe<FieldDefinitionNode>;
|
|
2381
|
+
/**
|
|
2382
|
+
* Creates a resolved GraphQL field definition.
|
|
2383
|
+
* @param parentType - Object or interface type that owns this field, if known.
|
|
2384
|
+
* @param name - Field name.
|
|
2385
|
+
* @param config - Field configuration.
|
|
2386
|
+
* @example
|
|
2387
|
+
* ```ts
|
|
2388
|
+
* import { parse } from 'graphql/language';
|
|
2389
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2390
|
+
*
|
|
2391
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2392
|
+
* const document = parse('type Query { greeting: String }');
|
|
2393
|
+
* const fieldNode = document.definitions[0].fields[0];
|
|
2394
|
+
* const field = new GraphQLField(Query, 'greeting', {
|
|
2395
|
+
* description: 'Greeting text.',
|
|
2396
|
+
* type: GraphQLString,
|
|
2397
|
+
* args: {
|
|
2398
|
+
* name: { type: GraphQLString, default: { value: 'world' } },
|
|
2399
|
+
* },
|
|
2400
|
+
* resolve: (_source, { name }) => `Hello, ${name}!`,
|
|
2401
|
+
* subscribe: async function* () {
|
|
2402
|
+
* yield { greeting: 'Hello!' };
|
|
2403
|
+
* },
|
|
2404
|
+
* deprecationReason: 'Use hello.',
|
|
2405
|
+
* extensions: { cacheSeconds: 60 },
|
|
2406
|
+
* astNode: fieldNode,
|
|
2407
|
+
* });
|
|
2408
|
+
*
|
|
2409
|
+
* field.parentType; // => Query
|
|
2410
|
+
* field.name; // => 'greeting'
|
|
2411
|
+
* field.args[0].default.value; // => 'world'
|
|
2412
|
+
* typeof field.subscribe; // => 'function'
|
|
2413
|
+
* field.deprecationReason; // => 'Use hello.'
|
|
2414
|
+
* field.astNode; // => fieldNode
|
|
2415
|
+
* ```
|
|
2416
|
+
*/
|
|
2417
|
+
constructor(parentType: GraphQLObjectType<TSource, TContext> | GraphQLInterfaceType<TSource, TContext> | undefined, name: string, config: GraphQLFieldConfig<TSource, TContext, TArgs>);
|
|
2418
|
+
/**
|
|
2419
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2420
|
+
* @returns The built-in string tag for this object.
|
|
2421
|
+
*/
|
|
2422
|
+
get [Symbol.toStringTag](): string;
|
|
2423
|
+
/**
|
|
2424
|
+
* Returns a normalized configuration object for this field.
|
|
2425
|
+
* @returns A configuration object that can be used to recreate this field.
|
|
2426
|
+
* @example
|
|
2427
|
+
* ```ts
|
|
2428
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2429
|
+
*
|
|
2430
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2431
|
+
* const field = new GraphQLField(Query, 'greeting', {
|
|
2432
|
+
* type: GraphQLString,
|
|
2433
|
+
* extensions: { cacheSeconds: 60 },
|
|
2434
|
+
* });
|
|
2435
|
+
*
|
|
2436
|
+
* field.toConfig().type; // => GraphQLString
|
|
2437
|
+
* field.toConfig().extensions; // => { cacheSeconds: 60 }
|
|
2438
|
+
* ```
|
|
2439
|
+
*/
|
|
2440
|
+
toConfig(): GraphQLFieldNormalizedConfig<TSource, TContext, TArgs>;
|
|
2441
|
+
/**
|
|
2442
|
+
* Returns this field as a schema coordinate string.
|
|
2443
|
+
* @returns The field coordinate.
|
|
2444
|
+
* @example
|
|
2445
|
+
* ```ts
|
|
2446
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2447
|
+
*
|
|
2448
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2449
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2450
|
+
*
|
|
2451
|
+
* field.toString(); // => 'Query.greeting'
|
|
2452
|
+
* ```
|
|
2453
|
+
*/
|
|
2454
|
+
toString(): string;
|
|
2455
|
+
/**
|
|
2456
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2457
|
+
* @returns The field coordinate.
|
|
2458
|
+
* @example
|
|
2459
|
+
* ```ts
|
|
2460
|
+
* import { GraphQLField, GraphQLObjectType, GraphQLString } from 'graphql/type';
|
|
2461
|
+
*
|
|
2462
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2463
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2464
|
+
*
|
|
2465
|
+
* JSON.stringify(field); // => '"Query.greeting"'
|
|
2466
|
+
* ```
|
|
2467
|
+
*/
|
|
2468
|
+
toJSON(): string;
|
|
2469
|
+
}
|
|
2470
|
+
/** A resolved GraphQL argument definition. */
|
|
2471
|
+
declare class GraphQLArgument implements GraphQLSchemaElement {
|
|
2472
|
+
/** Field or directive that owns this argument. */
|
|
2473
|
+
parent: GraphQLField | GraphQLDirective;
|
|
2474
|
+
/** The GraphQL name for this schema element. */
|
|
2475
|
+
name: string;
|
|
2476
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2477
|
+
description: Maybe<string>;
|
|
2478
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
2479
|
+
type: GraphQLInputType;
|
|
2480
|
+
/**
|
|
2481
|
+
* Deprecated legacy default value used when no explicit value is supplied.
|
|
2482
|
+
* Use `default` instead.
|
|
2483
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
2484
|
+
*/
|
|
2485
|
+
defaultValue: unknown;
|
|
2486
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
2487
|
+
default: GraphQLDefaultInput | undefined;
|
|
2488
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
2489
|
+
deprecationReason: Maybe<string>;
|
|
2490
|
+
/** Custom extension fields reserved for users. */
|
|
2491
|
+
extensions: Readonly<GraphQLArgumentExtensions>;
|
|
2492
|
+
/** AST node from which this schema element was built, if available. */
|
|
2493
|
+
astNode: Maybe<InputValueDefinitionNode>;
|
|
2494
|
+
/**
|
|
2495
|
+
* Creates a resolved GraphQL argument definition.
|
|
2496
|
+
* @param parent - Field or directive that owns this argument.
|
|
2497
|
+
* @param name - Argument name.
|
|
2498
|
+
* @param config - Argument configuration.
|
|
2499
|
+
* @example
|
|
2500
|
+
* ```ts
|
|
2501
|
+
* import {
|
|
2502
|
+
* GraphQLArgument,
|
|
2503
|
+
* GraphQLField,
|
|
2504
|
+
* GraphQLObjectType,
|
|
2505
|
+
* GraphQLString,
|
|
2506
|
+
* } from 'graphql/type';
|
|
2507
|
+
*
|
|
2508
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2509
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2510
|
+
* const arg = new GraphQLArgument(field, 'name', {
|
|
2511
|
+
* type: GraphQLString,
|
|
2512
|
+
* default: { value: 'world' },
|
|
2513
|
+
* });
|
|
2514
|
+
*
|
|
2515
|
+
* arg.parent; // => field
|
|
2516
|
+
* arg.name; // => 'name'
|
|
2517
|
+
* arg.default.value; // => 'world'
|
|
2518
|
+
* ```
|
|
2519
|
+
*/
|
|
2520
|
+
constructor(parent: GraphQLField | GraphQLDirective, name: string, config: GraphQLArgumentConfig);
|
|
2521
|
+
/**
|
|
2522
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2523
|
+
* @returns The built-in string tag for this object.
|
|
2524
|
+
*/
|
|
2525
|
+
get [Symbol.toStringTag](): string;
|
|
2526
|
+
/**
|
|
2527
|
+
* Returns a normalized configuration object for this argument.
|
|
2528
|
+
* @returns A configuration object that can be used to recreate this argument.
|
|
2529
|
+
* @example
|
|
2530
|
+
* ```ts
|
|
2531
|
+
* import {
|
|
2532
|
+
* GraphQLArgument,
|
|
2533
|
+
* GraphQLField,
|
|
2534
|
+
* GraphQLObjectType,
|
|
2535
|
+
* GraphQLString,
|
|
2536
|
+
* } from 'graphql/type';
|
|
2537
|
+
*
|
|
2538
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2539
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2540
|
+
* const arg = new GraphQLArgument(field, 'name', {
|
|
2541
|
+
* type: GraphQLString,
|
|
2542
|
+
* default: { value: 'world' },
|
|
2543
|
+
* });
|
|
2544
|
+
*
|
|
2545
|
+
* arg.toConfig().default.value; // => 'world'
|
|
2546
|
+
* ```
|
|
2547
|
+
*/
|
|
2548
|
+
toConfig(): GraphQLArgumentNormalizedConfig;
|
|
2549
|
+
/**
|
|
2550
|
+
* Returns this argument as a schema coordinate string.
|
|
2551
|
+
* @returns The argument coordinate.
|
|
2552
|
+
* @example
|
|
2553
|
+
* ```ts
|
|
2554
|
+
* import {
|
|
2555
|
+
* GraphQLArgument,
|
|
2556
|
+
* GraphQLField,
|
|
2557
|
+
* GraphQLObjectType,
|
|
2558
|
+
* GraphQLString,
|
|
2559
|
+
* } from 'graphql/type';
|
|
2560
|
+
*
|
|
2561
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2562
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2563
|
+
* const arg = new GraphQLArgument(field, 'name', { type: GraphQLString });
|
|
2564
|
+
*
|
|
2565
|
+
* arg.toString(); // => 'Query.greeting(name:)'
|
|
2566
|
+
* ```
|
|
2567
|
+
*/
|
|
2568
|
+
toString(): string;
|
|
2569
|
+
/**
|
|
2570
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2571
|
+
* @returns The argument coordinate.
|
|
2572
|
+
* @example
|
|
2573
|
+
* ```ts
|
|
2574
|
+
* import {
|
|
2575
|
+
* GraphQLArgument,
|
|
2576
|
+
* GraphQLField,
|
|
2577
|
+
* GraphQLObjectType,
|
|
2578
|
+
* GraphQLString,
|
|
2579
|
+
* } from 'graphql/type';
|
|
2580
|
+
*
|
|
2581
|
+
* const Query = new GraphQLObjectType({ name: 'Query', fields: {} });
|
|
2582
|
+
* const field = new GraphQLField(Query, 'greeting', { type: GraphQLString });
|
|
2583
|
+
* const arg = new GraphQLArgument(field, 'name', { type: GraphQLString });
|
|
2584
|
+
*
|
|
2585
|
+
* JSON.stringify(arg); // => '"Query.greeting(name:)"'
|
|
2586
|
+
* ```
|
|
2587
|
+
*/
|
|
2588
|
+
toJSON(): string;
|
|
2589
|
+
}
|
|
2590
|
+
/**
|
|
2591
|
+
* A map of field names to resolved field definitions.
|
|
2592
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2593
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2594
|
+
*/
|
|
2595
|
+
type GraphQLFieldMap<TSource, TContext> = ObjMap<GraphQLField<TSource, TContext>>;
|
|
2596
|
+
/** Default input represented as either a runtime value or a GraphQL literal. */
|
|
2597
|
+
type GraphQLDefaultInput = {
|
|
2598
|
+
/** Runtime default value. */value: unknown; /** GraphQL literal default value is not provided in this variant. */
|
|
2599
|
+
literal?: never;
|
|
2600
|
+
} | {
|
|
2601
|
+
/** GraphQL literal default value. */literal: ConstValueNode; /** Runtime default value is not provided in this variant. */
|
|
2602
|
+
value?: never;
|
|
2603
|
+
};
|
|
2604
|
+
/**
|
|
2605
|
+
* Custom extensions
|
|
2606
|
+
* @remarks
|
|
2607
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
2608
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
2609
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
2610
|
+
* an object which can contain all the values you need.
|
|
2611
|
+
*/
|
|
2612
|
+
interface GraphQLInterfaceTypeExtensions {
|
|
2613
|
+
[attributeName: string | symbol]: unknown;
|
|
2614
|
+
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Interface Type Definition
|
|
2617
|
+
*
|
|
2618
|
+
* When a field can return one of a heterogeneous set of types, a Interface type
|
|
2619
|
+
* is used to describe what types are possible, what fields are in common across
|
|
2620
|
+
* all types, as well as a function to determine which type is actually used
|
|
2621
|
+
* when the field is resolved.
|
|
2622
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2623
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2624
|
+
* @example
|
|
2625
|
+
* ```ts
|
|
2626
|
+
* const EntityType = new GraphQLInterfaceType({
|
|
2627
|
+
* name: 'Entity',
|
|
2628
|
+
* fields: {
|
|
2629
|
+
* name: { type: GraphQLString },
|
|
2630
|
+
* },
|
|
2631
|
+
* });
|
|
2632
|
+
* ```
|
|
2633
|
+
*/
|
|
2634
|
+
declare class GraphQLInterfaceType<TSource = any, TContext = any> implements GraphQLSchemaElement {
|
|
2635
|
+
/** The GraphQL name for this schema element. */
|
|
2636
|
+
name: string;
|
|
2637
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2638
|
+
description: Maybe<string>;
|
|
2639
|
+
/** Function that resolves the concrete object type for this abstract type. */
|
|
2640
|
+
resolveType: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
2641
|
+
/** Custom extension fields reserved for users. */
|
|
2642
|
+
extensions: Readonly<GraphQLInterfaceTypeExtensions>;
|
|
2643
|
+
/** AST node from which this schema element was built, if available. */
|
|
2644
|
+
astNode: Maybe<InterfaceTypeDefinitionNode>;
|
|
2645
|
+
/** AST extension nodes applied to this schema element. */
|
|
2646
|
+
extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
|
|
2647
|
+
private _fields;
|
|
2648
|
+
private _interfaces;
|
|
2649
|
+
/**
|
|
2650
|
+
* Creates a GraphQLInterfaceType instance.
|
|
2651
|
+
* @param config - Configuration describing this object.
|
|
2652
|
+
* @example
|
|
2653
|
+
* ```ts
|
|
2654
|
+
* import { parse } from 'graphql/language';
|
|
2655
|
+
* import { GraphQLID, GraphQLInterfaceType, GraphQLNonNull } from 'graphql/type';
|
|
2656
|
+
*
|
|
2657
|
+
* const document = parse(`
|
|
2658
|
+
* interface Node {
|
|
2659
|
+
* id: ID!
|
|
2660
|
+
* }
|
|
2661
|
+
*
|
|
2662
|
+
* interface Resource implements Node {
|
|
2663
|
+
* id: ID!
|
|
2664
|
+
* }
|
|
2665
|
+
*
|
|
2666
|
+
* extend interface Resource {
|
|
2667
|
+
* url: String
|
|
2668
|
+
* }
|
|
2669
|
+
* `);
|
|
2670
|
+
*
|
|
2671
|
+
* const Node = new GraphQLInterfaceType({
|
|
2672
|
+
* name: 'Node',
|
|
2673
|
+
* fields: {
|
|
2674
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
2675
|
+
* },
|
|
2676
|
+
* });
|
|
2677
|
+
*
|
|
2678
|
+
* const Resource = new GraphQLInterfaceType({
|
|
2679
|
+
* name: 'Resource',
|
|
2680
|
+
* description: 'An addressable resource.',
|
|
2681
|
+
* interfaces: [Node],
|
|
2682
|
+
* fields: {
|
|
2683
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
2684
|
+
* },
|
|
2685
|
+
* resolveType: (value) => {
|
|
2686
|
+
* return typeof value === 'object' && value != null && 'url' in value
|
|
2687
|
+
* ? 'WebPage'
|
|
2688
|
+
* : null;
|
|
2689
|
+
* },
|
|
2690
|
+
* extensions: { abstract: true },
|
|
2691
|
+
* astNode: document.definitions[1],
|
|
2692
|
+
* extensionASTNodes: [document.definitions[2]],
|
|
2693
|
+
* });
|
|
2694
|
+
*
|
|
2695
|
+
* Resource.name; // => 'Resource'
|
|
2696
|
+
* Resource.getInterfaces(); // => [Node]
|
|
2697
|
+
* Object.keys(Resource.getFields()); // => ['id']
|
|
2698
|
+
* Resource.extensions; // => { abstract: true }
|
|
2699
|
+
* ```
|
|
2700
|
+
*/
|
|
2701
|
+
constructor(config: Readonly<GraphQLInterfaceTypeConfig<TSource, TContext>>);
|
|
2702
|
+
/**
|
|
2703
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2704
|
+
* @returns The built-in string tag for this object.
|
|
2705
|
+
*/
|
|
2706
|
+
get [Symbol.toStringTag](): string;
|
|
2707
|
+
/**
|
|
2708
|
+
* Returns the fields defined by this type.
|
|
2709
|
+
* @returns The fields keyed by field name.
|
|
2710
|
+
* @example
|
|
2711
|
+
* ```ts
|
|
2712
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2713
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
2714
|
+
*
|
|
2715
|
+
* const schema = buildSchema(`
|
|
2716
|
+
* interface Node {
|
|
2717
|
+
* id: ID!
|
|
2718
|
+
* }
|
|
2719
|
+
*
|
|
2720
|
+
* type User implements Node {
|
|
2721
|
+
* id: ID!
|
|
2722
|
+
* }
|
|
2723
|
+
*
|
|
2724
|
+
* type Query {
|
|
2725
|
+
* node: Node
|
|
2726
|
+
* }
|
|
2727
|
+
* `);
|
|
2728
|
+
*
|
|
2729
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
2730
|
+
* const fields = Node.getFields();
|
|
2731
|
+
*
|
|
2732
|
+
* Object.keys(fields); // => ['id']
|
|
2733
|
+
* String(fields.id.type); // => 'ID!'
|
|
2734
|
+
* ```
|
|
2735
|
+
*/
|
|
2736
|
+
getFields(): GraphQLFieldMap<TSource, TContext>;
|
|
2737
|
+
/**
|
|
2738
|
+
* Returns the interfaces implemented by this type.
|
|
2739
|
+
* @returns The implemented interfaces.
|
|
2740
|
+
* @example
|
|
2741
|
+
* ```ts
|
|
2742
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2743
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
2744
|
+
*
|
|
2745
|
+
* const schema = buildSchema(`
|
|
2746
|
+
* interface Resource {
|
|
2747
|
+
* url: String!
|
|
2748
|
+
* }
|
|
2749
|
+
*
|
|
2750
|
+
* interface Image implements Resource {
|
|
2751
|
+
* url: String!
|
|
2752
|
+
* width: Int
|
|
2753
|
+
* }
|
|
2754
|
+
*
|
|
2755
|
+
* type Photo implements Resource & Image {
|
|
2756
|
+
* url: String!
|
|
2757
|
+
* width: Int
|
|
2758
|
+
* }
|
|
2759
|
+
*
|
|
2760
|
+
* type Query {
|
|
2761
|
+
* image: Image
|
|
2762
|
+
* }
|
|
2763
|
+
* `);
|
|
2764
|
+
*
|
|
2765
|
+
* const Image = assertInterfaceType(schema.getType('Image'));
|
|
2766
|
+
*
|
|
2767
|
+
* Image.getInterfaces().map((type) => type.name); // => ['Resource']
|
|
2768
|
+
* ```
|
|
2769
|
+
*/
|
|
2770
|
+
getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
|
|
2771
|
+
/**
|
|
2772
|
+
* Returns a normalized configuration object for this object.
|
|
2773
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
2774
|
+
* @example
|
|
2775
|
+
* ```ts
|
|
2776
|
+
* import { GraphQLID, GraphQLInterfaceType, GraphQLNonNull } from 'graphql/type';
|
|
2777
|
+
*
|
|
2778
|
+
* const Node = new GraphQLInterfaceType({
|
|
2779
|
+
* name: 'Node',
|
|
2780
|
+
* fields: {
|
|
2781
|
+
* id: { type: new GraphQLNonNull(GraphQLID) },
|
|
2782
|
+
* },
|
|
2783
|
+
* });
|
|
2784
|
+
*
|
|
2785
|
+
* const config = Node.toConfig();
|
|
2786
|
+
* const NodeCopy = new GraphQLInterfaceType(config);
|
|
2787
|
+
*
|
|
2788
|
+
* String(config.fields.id.type); // => 'ID!'
|
|
2789
|
+
* String(NodeCopy.getFields().id.type); // => 'ID!'
|
|
2790
|
+
* ```
|
|
2791
|
+
*/
|
|
2792
|
+
toConfig(): GraphQLInterfaceTypeNormalizedConfig<TSource, TContext>;
|
|
2793
|
+
/**
|
|
2794
|
+
* Returns the schema coordinate identifying this interface type.
|
|
2795
|
+
* @returns The schema coordinate for this interface type.
|
|
2796
|
+
* @example
|
|
2797
|
+
* ```ts
|
|
2798
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2799
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
2800
|
+
*
|
|
2801
|
+
* const schema = buildSchema(`
|
|
2802
|
+
* interface Node {
|
|
2803
|
+
* id: ID!
|
|
2804
|
+
* }
|
|
2805
|
+
*
|
|
2806
|
+
* type User implements Node {
|
|
2807
|
+
* id: ID!
|
|
2808
|
+
* }
|
|
2809
|
+
*
|
|
2810
|
+
* type Query {
|
|
2811
|
+
* node: Node
|
|
2812
|
+
* }
|
|
2813
|
+
* `);
|
|
2814
|
+
*
|
|
2815
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
2816
|
+
*
|
|
2817
|
+
* Node.toString(); // => 'Node'
|
|
2818
|
+
* ```
|
|
2819
|
+
*/
|
|
2820
|
+
toString(): string;
|
|
2821
|
+
/**
|
|
2822
|
+
* Returns the JSON representation used when this object is serialized.
|
|
2823
|
+
* @returns The JSON-serializable representation.
|
|
2824
|
+
* @example
|
|
2825
|
+
* ```ts
|
|
2826
|
+
* import { GraphQLInterfaceType, GraphQLString } from 'graphql/type';
|
|
2827
|
+
*
|
|
2828
|
+
* const Named = new GraphQLInterfaceType({
|
|
2829
|
+
* name: 'Named',
|
|
2830
|
+
* fields: { name: { type: GraphQLString } },
|
|
2831
|
+
* });
|
|
2832
|
+
*
|
|
2833
|
+
* Named.toJSON(); // => 'Named'
|
|
2834
|
+
* JSON.stringify({ type: Named }); // => '{"type":"Named"}'
|
|
2835
|
+
* ```
|
|
2836
|
+
*/
|
|
2837
|
+
toJSON(): string;
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Configuration used to construct a GraphQLInterfaceType.
|
|
2841
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2842
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2843
|
+
*/
|
|
2844
|
+
interface GraphQLInterfaceTypeConfig<TSource, TContext> {
|
|
2845
|
+
/** The GraphQL name for this schema element. */
|
|
2846
|
+
name: string;
|
|
2847
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2848
|
+
description?: Maybe<string>;
|
|
2849
|
+
/** Interfaces implemented by this object or interface type. */
|
|
2850
|
+
interfaces?: ThunkReadonlyArray<GraphQLInterfaceType> | undefined;
|
|
2851
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
2852
|
+
fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
|
|
2853
|
+
/**
|
|
2854
|
+
* Optionally provide a custom type resolver function. If one is not provided,
|
|
2855
|
+
* the default implementation will call `isTypeOf` on each implementing
|
|
2856
|
+
* Object type.
|
|
2857
|
+
*/
|
|
2858
|
+
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
2859
|
+
/** Custom extension fields reserved for users. */
|
|
2860
|
+
extensions?: Maybe<Readonly<GraphQLInterfaceTypeExtensions>>;
|
|
2861
|
+
/** AST node from which this schema element was built, if available. */
|
|
2862
|
+
astNode?: Maybe<InterfaceTypeDefinitionNode>;
|
|
2863
|
+
/** AST extension nodes applied to this schema element. */
|
|
2864
|
+
extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
|
|
2865
|
+
}
|
|
2866
|
+
/** @internal */
|
|
2867
|
+
interface GraphQLInterfaceTypeNormalizedConfig<TSource, TContext> extends GraphQLInterfaceTypeConfig<TSource, TContext> {
|
|
2868
|
+
interfaces: ReadonlyArray<GraphQLInterfaceType>;
|
|
2869
|
+
fields: GraphQLFieldNormalizedConfigMap<TSource, TContext>;
|
|
2870
|
+
extensions: Readonly<GraphQLInterfaceTypeExtensions>;
|
|
2871
|
+
extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
|
|
2872
|
+
}
|
|
2873
|
+
/**
|
|
2874
|
+
* Custom extensions
|
|
2875
|
+
* @remarks
|
|
2876
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
2877
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
2878
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
2879
|
+
* an object which can contain all the values you need.
|
|
2880
|
+
*/
|
|
2881
|
+
interface GraphQLUnionTypeExtensions {
|
|
2882
|
+
[attributeName: string | symbol]: unknown;
|
|
2883
|
+
}
|
|
2884
|
+
/**
|
|
2885
|
+
* Union Type Definition
|
|
2886
|
+
*
|
|
2887
|
+
* When a field can return one of a heterogeneous set of types, a Union type
|
|
2888
|
+
* is used to describe what types are possible as well as providing a function
|
|
2889
|
+
* to determine which type is actually used when the field is resolved.
|
|
2890
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
2891
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
2892
|
+
* @example
|
|
2893
|
+
* ```ts
|
|
2894
|
+
* const PetType = new GraphQLUnionType({
|
|
2895
|
+
* name: 'Pet',
|
|
2896
|
+
* types: [DogType, CatType],
|
|
2897
|
+
* resolveType: (value) => {
|
|
2898
|
+
* if (value instanceof Dog) {
|
|
2899
|
+
* return DogType;
|
|
2900
|
+
* }
|
|
2901
|
+
* if (value instanceof Cat) {
|
|
2902
|
+
* return CatType;
|
|
2903
|
+
* }
|
|
2904
|
+
* },
|
|
2905
|
+
* });
|
|
2906
|
+
* ```
|
|
2907
|
+
*/
|
|
2908
|
+
declare class GraphQLUnionType<TSource = any, TContext = any> implements GraphQLSchemaElement {
|
|
2909
|
+
/** The GraphQL name for this schema element. */
|
|
2910
|
+
name: string;
|
|
2911
|
+
/** Human-readable description for this schema element, if provided. */
|
|
2912
|
+
description: Maybe<string>;
|
|
2913
|
+
/** Function that resolves the concrete object type for this abstract type. */
|
|
2914
|
+
resolveType: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
2915
|
+
/** Custom extension fields reserved for users. */
|
|
2916
|
+
extensions: Readonly<GraphQLUnionTypeExtensions>;
|
|
2917
|
+
/** AST node from which this schema element was built, if available. */
|
|
2918
|
+
astNode: Maybe<UnionTypeDefinitionNode>;
|
|
2919
|
+
/** AST extension nodes applied to this schema element. */
|
|
2920
|
+
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
|
|
2921
|
+
private _types;
|
|
2922
|
+
/**
|
|
2923
|
+
* Creates a GraphQLUnionType instance.
|
|
2924
|
+
* @param config - Configuration describing this object.
|
|
2925
|
+
* @example
|
|
2926
|
+
* ```ts
|
|
2927
|
+
* import { parse } from 'graphql/language';
|
|
2928
|
+
* import {
|
|
2929
|
+
* GraphQLObjectType,
|
|
2930
|
+
* GraphQLString,
|
|
2931
|
+
* GraphQLUnionType,
|
|
2932
|
+
* } from 'graphql/type';
|
|
2933
|
+
*
|
|
2934
|
+
* const document = parse(`
|
|
2935
|
+
* union Media = Photo | Video
|
|
2936
|
+
*
|
|
2937
|
+
* extend union Media = Audio
|
|
2938
|
+
* `);
|
|
2939
|
+
*
|
|
2940
|
+
* const Photo = new GraphQLObjectType({
|
|
2941
|
+
* name: 'Photo',
|
|
2942
|
+
* fields: { url: { type: GraphQLString } },
|
|
2943
|
+
* });
|
|
2944
|
+
* const Video = new GraphQLObjectType({
|
|
2945
|
+
* name: 'Video',
|
|
2946
|
+
* fields: { url: { type: GraphQLString } },
|
|
2947
|
+
* });
|
|
2948
|
+
*
|
|
2949
|
+
* const Media = new GraphQLUnionType({
|
|
2950
|
+
* name: 'Media',
|
|
2951
|
+
* description: 'Media that can appear in a search result.',
|
|
2952
|
+
* types: [Photo, Video],
|
|
2953
|
+
* resolveType: (value) => {
|
|
2954
|
+
* return typeof value === 'object' && value != null && 'duration' in value
|
|
2955
|
+
* ? 'Video'
|
|
2956
|
+
* : 'Photo';
|
|
2957
|
+
* },
|
|
2958
|
+
* extensions: { searchable: true },
|
|
2959
|
+
* astNode: document.definitions[0],
|
|
2960
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
2961
|
+
* });
|
|
2962
|
+
*
|
|
2963
|
+
* Media.description; // => 'Media that can appear in a search result.'
|
|
2964
|
+
* Media.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
2965
|
+
* Media.extensions; // => { searchable: true }
|
|
2966
|
+
* ```
|
|
2967
|
+
*/
|
|
2968
|
+
constructor(config: Readonly<GraphQLUnionTypeConfig<TSource, TContext>>);
|
|
2969
|
+
/**
|
|
2970
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
2971
|
+
* @returns The built-in string tag for this object.
|
|
2972
|
+
*/
|
|
2973
|
+
get [Symbol.toStringTag](): string;
|
|
2974
|
+
/**
|
|
2975
|
+
* Returns the object types included in this union.
|
|
2976
|
+
* @returns The union member object types.
|
|
2977
|
+
* @example
|
|
2978
|
+
* ```ts
|
|
2979
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
2980
|
+
* import { assertUnionType } from 'graphql/type';
|
|
2981
|
+
*
|
|
2982
|
+
* const schema = buildSchema(`
|
|
2983
|
+
* type Photo {
|
|
2984
|
+
* url: String!
|
|
2985
|
+
* }
|
|
2986
|
+
*
|
|
2987
|
+
* type Video {
|
|
2988
|
+
* url: String!
|
|
2989
|
+
* }
|
|
2990
|
+
*
|
|
2991
|
+
* union Media = Photo | Video
|
|
2992
|
+
*
|
|
2993
|
+
* type Query {
|
|
2994
|
+
* media: [Media]
|
|
2995
|
+
* }
|
|
2996
|
+
* `);
|
|
2997
|
+
*
|
|
2998
|
+
* const Media = assertUnionType(schema.getType('Media'));
|
|
2999
|
+
*
|
|
3000
|
+
* Media.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
3001
|
+
* ```
|
|
3002
|
+
*/
|
|
3003
|
+
getTypes(): ReadonlyArray<GraphQLObjectType>;
|
|
3004
|
+
/**
|
|
3005
|
+
* Returns a normalized configuration object for this object.
|
|
3006
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
3007
|
+
* @example
|
|
3008
|
+
* ```ts
|
|
3009
|
+
* import {
|
|
3010
|
+
* GraphQLObjectType,
|
|
3011
|
+
* GraphQLString,
|
|
3012
|
+
* GraphQLUnionType,
|
|
3013
|
+
* } from 'graphql/type';
|
|
3014
|
+
*
|
|
3015
|
+
* const Photo = new GraphQLObjectType({
|
|
3016
|
+
* name: 'Photo',
|
|
3017
|
+
* fields: { url: { type: GraphQLString } },
|
|
3018
|
+
* });
|
|
3019
|
+
* const Video = new GraphQLObjectType({
|
|
3020
|
+
* name: 'Video',
|
|
3021
|
+
* fields: { url: { type: GraphQLString } },
|
|
3022
|
+
* });
|
|
3023
|
+
* const Media = new GraphQLUnionType({
|
|
3024
|
+
* name: 'Media',
|
|
3025
|
+
* types: [Photo, Video],
|
|
3026
|
+
* });
|
|
3027
|
+
*
|
|
3028
|
+
* const config = Media.toConfig();
|
|
3029
|
+
* const MediaCopy = new GraphQLUnionType(config);
|
|
3030
|
+
*
|
|
3031
|
+
* MediaCopy.getTypes().map((type) => type.name); // => ['Photo', 'Video']
|
|
3032
|
+
* ```
|
|
3033
|
+
*/
|
|
3034
|
+
toConfig(): GraphQLUnionTypeNormalizedConfig<TSource, TContext>;
|
|
3035
|
+
/**
|
|
3036
|
+
* Returns the schema coordinate identifying this union type.
|
|
3037
|
+
* @returns The schema coordinate for this union type.
|
|
3038
|
+
* @example
|
|
3039
|
+
* ```ts
|
|
3040
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3041
|
+
* import { assertUnionType } from 'graphql/type';
|
|
3042
|
+
*
|
|
3043
|
+
* const schema = buildSchema(`
|
|
3044
|
+
* type Photo {
|
|
3045
|
+
* url: String!
|
|
3046
|
+
* }
|
|
3047
|
+
*
|
|
3048
|
+
* union SearchResult = Photo
|
|
3049
|
+
*
|
|
3050
|
+
* type Query {
|
|
3051
|
+
* search: [SearchResult]
|
|
3052
|
+
* }
|
|
3053
|
+
* `);
|
|
3054
|
+
*
|
|
3055
|
+
* const SearchResult = assertUnionType(schema.getType('SearchResult'));
|
|
3056
|
+
*
|
|
3057
|
+
* SearchResult.toString(); // => 'SearchResult'
|
|
3058
|
+
* ```
|
|
3059
|
+
*/
|
|
3060
|
+
toString(): string;
|
|
3061
|
+
/**
|
|
3062
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3063
|
+
* @returns The JSON-serializable representation.
|
|
3064
|
+
* @example
|
|
3065
|
+
* ```ts
|
|
3066
|
+
* import {
|
|
3067
|
+
* GraphQLObjectType,
|
|
3068
|
+
* GraphQLString,
|
|
3069
|
+
* GraphQLUnionType,
|
|
3070
|
+
* } from 'graphql/type';
|
|
3071
|
+
*
|
|
3072
|
+
* const Photo = new GraphQLObjectType({
|
|
3073
|
+
* name: 'Photo',
|
|
3074
|
+
* fields: { url: { type: GraphQLString } },
|
|
3075
|
+
* });
|
|
3076
|
+
* const SearchResult = new GraphQLUnionType({
|
|
3077
|
+
* name: 'SearchResult',
|
|
3078
|
+
* types: [Photo],
|
|
3079
|
+
* });
|
|
3080
|
+
*
|
|
3081
|
+
* SearchResult.toJSON(); // => 'SearchResult'
|
|
3082
|
+
* JSON.stringify({ type: SearchResult }); // => '{"type":"SearchResult"}'
|
|
3083
|
+
* ```
|
|
3084
|
+
*/
|
|
3085
|
+
toJSON(): string;
|
|
3086
|
+
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Configuration used to construct a GraphQLUnionType.
|
|
3089
|
+
* @typeParam TSource - Source object type passed to resolvers.
|
|
3090
|
+
* @typeParam TContext - Context object type passed to resolvers.
|
|
3091
|
+
*/
|
|
3092
|
+
interface GraphQLUnionTypeConfig<TSource, TContext> {
|
|
3093
|
+
/** The GraphQL name for this schema element. */
|
|
3094
|
+
name: string;
|
|
3095
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3096
|
+
description?: Maybe<string>;
|
|
3097
|
+
/** Object types that belong to this union type. */
|
|
3098
|
+
types: ThunkReadonlyArray<GraphQLObjectType>;
|
|
3099
|
+
/**
|
|
3100
|
+
* Optionally provide a custom type resolver function. If one is not provided,
|
|
3101
|
+
* the default implementation will call `isTypeOf` on each implementing
|
|
3102
|
+
* Object type.
|
|
3103
|
+
*/
|
|
3104
|
+
resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
|
|
3105
|
+
/** Custom extension fields reserved for users. */
|
|
3106
|
+
extensions?: Maybe<Readonly<GraphQLUnionTypeExtensions>>;
|
|
3107
|
+
/** AST node from which this schema element was built, if available. */
|
|
3108
|
+
astNode?: Maybe<UnionTypeDefinitionNode>;
|
|
3109
|
+
/** AST extension nodes applied to this schema element. */
|
|
3110
|
+
extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
|
|
3111
|
+
}
|
|
3112
|
+
/** @internal */
|
|
3113
|
+
interface GraphQLUnionTypeNormalizedConfig<TSource, TContext> extends GraphQLUnionTypeConfig<TSource, TContext> {
|
|
3114
|
+
types: ReadonlyArray<GraphQLObjectType>;
|
|
3115
|
+
extensions: Readonly<GraphQLUnionTypeExtensions>;
|
|
3116
|
+
extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* Custom extensions
|
|
3120
|
+
* @remarks
|
|
3121
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
3122
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
3123
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
3124
|
+
* an object which can contain all the values you need.
|
|
3125
|
+
*/
|
|
3126
|
+
interface GraphQLEnumTypeExtensions {
|
|
3127
|
+
[attributeName: string | symbol]: unknown;
|
|
3128
|
+
}
|
|
3129
|
+
/**
|
|
3130
|
+
* Enum Type Definition
|
|
3131
|
+
*
|
|
3132
|
+
* Enum types define leaf values whose serialized form is one of a fixed set
|
|
3133
|
+
* of GraphQL enum names. Internally, enum values can map to any runtime value,
|
|
3134
|
+
* often integers.
|
|
3135
|
+
* @example
|
|
3136
|
+
* ```ts
|
|
3137
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3138
|
+
*
|
|
3139
|
+
* const RGBType = new GraphQLEnumType({
|
|
3140
|
+
* name: 'RGB',
|
|
3141
|
+
* values: {
|
|
3142
|
+
* RED: { value: 0 },
|
|
3143
|
+
* GREEN: { value: 1 },
|
|
3144
|
+
* BLUE: { value: 2 },
|
|
3145
|
+
* },
|
|
3146
|
+
* });
|
|
3147
|
+
*
|
|
3148
|
+
* RGBType.getValue('GREEN')?.value; // => 1
|
|
3149
|
+
* ```
|
|
3150
|
+
*
|
|
3151
|
+
* Note: If a value is not provided in a definition, the name of the enum value
|
|
3152
|
+
* will be used as its internal value.
|
|
3153
|
+
*/
|
|
3154
|
+
declare class GraphQLEnumType implements GraphQLSchemaElement {
|
|
3155
|
+
/** The GraphQL name for this schema element. */
|
|
3156
|
+
name: string;
|
|
3157
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3158
|
+
description: Maybe<string>;
|
|
3159
|
+
/** Custom extension fields reserved for users. */
|
|
3160
|
+
extensions: Readonly<GraphQLEnumTypeExtensions>;
|
|
3161
|
+
/** AST node from which this schema element was built, if available. */
|
|
3162
|
+
astNode: Maybe<EnumTypeDefinitionNode>;
|
|
3163
|
+
/** AST extension nodes applied to this schema element. */
|
|
3164
|
+
extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
|
|
3165
|
+
private _values;
|
|
3166
|
+
private _valueLookup;
|
|
3167
|
+
private _nameLookup;
|
|
3168
|
+
/**
|
|
3169
|
+
* Creates a GraphQLEnumType instance.
|
|
3170
|
+
* @param config - Configuration describing this object.
|
|
3171
|
+
* @example
|
|
3172
|
+
* ```ts
|
|
3173
|
+
* import { parse } from 'graphql/language';
|
|
3174
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3175
|
+
*
|
|
3176
|
+
* const document = parse(`
|
|
3177
|
+
* enum Episode {
|
|
3178
|
+
* NEW_HOPE
|
|
3179
|
+
* EMPIRE
|
|
3180
|
+
* JEDI
|
|
3181
|
+
* }
|
|
3182
|
+
*
|
|
3183
|
+
* extend enum Episode {
|
|
3184
|
+
* FORCE_AWAKENS
|
|
3185
|
+
* }
|
|
3186
|
+
* `);
|
|
3187
|
+
* const definition = document.definitions[0];
|
|
3188
|
+
*
|
|
3189
|
+
* const Episode = new GraphQLEnumType({
|
|
3190
|
+
* name: 'Episode',
|
|
3191
|
+
* description: 'A Star Wars film episode.',
|
|
3192
|
+
* values: {
|
|
3193
|
+
* NEW_HOPE: {
|
|
3194
|
+
* value: 4,
|
|
3195
|
+
* description: 'Released in 1977.',
|
|
3196
|
+
* extensions: { trilogy: 'original' },
|
|
3197
|
+
* astNode: definition.values[0],
|
|
3198
|
+
* },
|
|
3199
|
+
* EMPIRE: { value: 5, astNode: definition.values[1] },
|
|
3200
|
+
* JEDI: {
|
|
3201
|
+
* value: 6,
|
|
3202
|
+
* deprecationReason: 'Use RETURN_OF_THE_JEDI.',
|
|
3203
|
+
* astNode: definition.values[2],
|
|
3204
|
+
* },
|
|
3205
|
+
* },
|
|
3206
|
+
* extensions: { catalog: 'films' },
|
|
3207
|
+
* astNode: definition,
|
|
3208
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
3209
|
+
* });
|
|
3210
|
+
*
|
|
3211
|
+
* Episode.description; // => 'A Star Wars film episode.'
|
|
3212
|
+
* Episode.coerceOutputValue(5); // => 'EMPIRE'
|
|
3213
|
+
* Episode.coerceInputValue('JEDI'); // => 6
|
|
3214
|
+
* Episode.getValue('JEDI').deprecationReason; // => 'Use RETURN_OF_THE_JEDI.'
|
|
3215
|
+
* Episode.extensions; // => { catalog: 'films' }
|
|
3216
|
+
* ```
|
|
3217
|
+
*/
|
|
3218
|
+
constructor(config: Readonly<GraphQLEnumTypeConfig>);
|
|
3219
|
+
/**
|
|
3220
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3221
|
+
* @returns The built-in string tag for this object.
|
|
3222
|
+
*/
|
|
3223
|
+
get [Symbol.toStringTag](): string;
|
|
3224
|
+
/**
|
|
3225
|
+
* Returns the values defined by this enum type.
|
|
3226
|
+
* @returns Enum value definitions in schema order.
|
|
3227
|
+
* @example
|
|
3228
|
+
* ```ts
|
|
3229
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3230
|
+
* import { assertEnumType } from 'graphql/type';
|
|
3231
|
+
*
|
|
3232
|
+
* const schema = buildSchema(`
|
|
3233
|
+
* enum Episode {
|
|
3234
|
+
* NEW_HOPE
|
|
3235
|
+
* EMPIRE
|
|
3236
|
+
* JEDI
|
|
3237
|
+
* }
|
|
3238
|
+
*
|
|
3239
|
+
* type Query {
|
|
3240
|
+
* episode: Episode
|
|
3241
|
+
* }
|
|
3242
|
+
* `);
|
|
3243
|
+
*
|
|
3244
|
+
* const Episode = assertEnumType(schema.getType('Episode'));
|
|
3245
|
+
*
|
|
3246
|
+
* Episode.getValues().map((value) => value.name); // => ['NEW_HOPE', 'EMPIRE', 'JEDI']
|
|
3247
|
+
* ```
|
|
3248
|
+
*/
|
|
3249
|
+
getValues(): ReadonlyArray<GraphQLEnumValue>;
|
|
3250
|
+
/**
|
|
3251
|
+
* Returns the enum value definition for a value name.
|
|
3252
|
+
* @param name - The GraphQL name to look up.
|
|
3253
|
+
* @returns The matching enum value definition, if it exists.
|
|
3254
|
+
* @example
|
|
3255
|
+
* ```ts
|
|
3256
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3257
|
+
* import { assertEnumType } from 'graphql/type';
|
|
3258
|
+
*
|
|
3259
|
+
* const schema = buildSchema(`
|
|
3260
|
+
* enum Episode {
|
|
3261
|
+
* NEW_HOPE
|
|
3262
|
+
* EMPIRE
|
|
3263
|
+
* }
|
|
3264
|
+
*
|
|
3265
|
+
* type Query {
|
|
3266
|
+
* episode: Episode
|
|
3267
|
+
* }
|
|
3268
|
+
* `);
|
|
3269
|
+
*
|
|
3270
|
+
* const Episode = assertEnumType(schema.getType('Episode'));
|
|
3271
|
+
*
|
|
3272
|
+
* Episode.getValue('EMPIRE')?.name; // => 'EMPIRE'
|
|
3273
|
+
* Episode.getValue('JEDI'); // => undefined
|
|
3274
|
+
* ```
|
|
3275
|
+
*/
|
|
3276
|
+
getValue(name: string): Maybe<GraphQLEnumValue>;
|
|
3277
|
+
/**
|
|
3278
|
+
* Serializes a runtime enum value as a GraphQL enum name.
|
|
3279
|
+
* @param outputValue - Runtime enum value to serialize.
|
|
3280
|
+
* @returns The GraphQL enum name for the runtime value.
|
|
3281
|
+
*
|
|
3282
|
+
* This deprecated method delegates to `coerceOutputValue()`; call
|
|
3283
|
+
* `coerceOutputValue()` directly instead.
|
|
3284
|
+
* @example
|
|
3285
|
+
* ```ts
|
|
3286
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3287
|
+
*
|
|
3288
|
+
* const RGB = new GraphQLEnumType({
|
|
3289
|
+
* name: 'RGB',
|
|
3290
|
+
* values: {
|
|
3291
|
+
* RED: { value: 0 },
|
|
3292
|
+
* GREEN: { value: 1 },
|
|
3293
|
+
* BLUE: { value: 2 },
|
|
3294
|
+
* },
|
|
3295
|
+
* });
|
|
3296
|
+
*
|
|
3297
|
+
* RGB.serialize(1); // => 'GREEN'
|
|
3298
|
+
* RGB.serialize(3); // throws an error
|
|
3299
|
+
* ```
|
|
3300
|
+
* @deprecated use `coerceOutputValue()` instead, `serialize()` will be removed in v18
|
|
3301
|
+
*/
|
|
3302
|
+
serialize(outputValue: unknown): Maybe<string>;
|
|
3303
|
+
/**
|
|
3304
|
+
* Coerces a runtime enum value to a GraphQL enum name.
|
|
3305
|
+
* @param outputValue - Runtime enum value to coerce.
|
|
3306
|
+
* @returns The GraphQL enum name for the runtime value.
|
|
3307
|
+
* @example
|
|
3308
|
+
* ```ts
|
|
3309
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3310
|
+
*
|
|
3311
|
+
* const RGB = new GraphQLEnumType({
|
|
3312
|
+
* name: 'RGB',
|
|
3313
|
+
* values: {
|
|
3314
|
+
* RED: { value: 0 },
|
|
3315
|
+
* GREEN: { value: 1 },
|
|
3316
|
+
* BLUE: { value: 2 },
|
|
3317
|
+
* },
|
|
3318
|
+
* });
|
|
3319
|
+
*
|
|
3320
|
+
* RGB.coerceOutputValue(1); // => 'GREEN'
|
|
3321
|
+
* RGB.coerceOutputValue(3); // throws an error
|
|
3322
|
+
* ```
|
|
3323
|
+
*/
|
|
3324
|
+
coerceOutputValue(outputValue: unknown): Maybe<string>;
|
|
3325
|
+
/**
|
|
3326
|
+
* Deprecated legacy enum parser for externally provided input values. Use
|
|
3327
|
+
* `coerceInputValue()` instead.
|
|
3328
|
+
* @param inputValue - External enum name to parse.
|
|
3329
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3330
|
+
* @returns The internal runtime value for the enum name.
|
|
3331
|
+
* @example
|
|
3332
|
+
* ```ts
|
|
3333
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3334
|
+
*
|
|
3335
|
+
* const RGB = new GraphQLEnumType({
|
|
3336
|
+
* name: 'RGB',
|
|
3337
|
+
* values: {
|
|
3338
|
+
* RED: { value: 0 },
|
|
3339
|
+
* GREEN: { value: 1 },
|
|
3340
|
+
* BLUE: { value: 2 },
|
|
3341
|
+
* },
|
|
3342
|
+
* });
|
|
3343
|
+
*
|
|
3344
|
+
* RGB.parseValue('BLUE'); // => 2
|
|
3345
|
+
* RGB.parseValue('PURPLE', true); // throws an error
|
|
3346
|
+
* ```
|
|
3347
|
+
* @deprecated use `coerceInputValue()` instead, `parseValue()` will be removed in v18
|
|
3348
|
+
*/
|
|
3349
|
+
parseValue(inputValue: unknown, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3350
|
+
/**
|
|
3351
|
+
* Coerces an external enum name to its internal runtime value.
|
|
3352
|
+
* @param inputValue - External enum name to coerce.
|
|
3353
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3354
|
+
* @returns The internal runtime value for the enum name.
|
|
3355
|
+
* @example
|
|
3356
|
+
* ```ts
|
|
3357
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3358
|
+
*
|
|
3359
|
+
* const RGB = new GraphQLEnumType({
|
|
3360
|
+
* name: 'RGB',
|
|
3361
|
+
* values: {
|
|
3362
|
+
* RED: { value: 0 },
|
|
3363
|
+
* GREEN: { value: 1 },
|
|
3364
|
+
* BLUE: { value: 2 },
|
|
3365
|
+
* },
|
|
3366
|
+
* });
|
|
3367
|
+
*
|
|
3368
|
+
* RGB.coerceInputValue('BLUE'); // => 2
|
|
3369
|
+
* RGB.coerceInputValue('PURPLE'); // throws an error
|
|
3370
|
+
* RGB.coerceInputValue(2); // throws an error
|
|
3371
|
+
* ```
|
|
3372
|
+
*/
|
|
3373
|
+
coerceInputValue(inputValue: unknown, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3374
|
+
/**
|
|
3375
|
+
* Deprecated legacy enum parser for externally provided input literals. Use
|
|
3376
|
+
* `coerceInputLiteral()` instead.
|
|
3377
|
+
* @param valueNode - Enum value AST node to parse.
|
|
3378
|
+
* @param _variables - Deprecated variable values parameter that is no longer used.
|
|
3379
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3380
|
+
* @returns The internal runtime value for the enum literal.
|
|
3381
|
+
* @example
|
|
3382
|
+
* ```ts
|
|
3383
|
+
* import { parseValue } from 'graphql/language';
|
|
3384
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3385
|
+
*
|
|
3386
|
+
* const RGB = new GraphQLEnumType({
|
|
3387
|
+
* name: 'RGB',
|
|
3388
|
+
* values: {
|
|
3389
|
+
* RED: { value: 0 },
|
|
3390
|
+
* GREEN: { value: 1 },
|
|
3391
|
+
* BLUE: { value: 2 },
|
|
3392
|
+
* },
|
|
3393
|
+
* });
|
|
3394
|
+
*
|
|
3395
|
+
* RGB.parseLiteral(parseValue('RED')); // => 0
|
|
3396
|
+
* RGB.parseLiteral(parseValue('"RED"')); // throws an error
|
|
3397
|
+
* ```
|
|
3398
|
+
* @deprecated use `coerceInputLiteral()` instead, `parseLiteral()` will be removed in v18
|
|
3399
|
+
*/
|
|
3400
|
+
parseLiteral(valueNode: ValueNode, _variables: Maybe<ObjMap<unknown>>, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3401
|
+
/**
|
|
3402
|
+
* Coerces an enum value AST node to its internal runtime value.
|
|
3403
|
+
* @param valueNode - Enum value AST node to coerce.
|
|
3404
|
+
* @param hideSuggestions - Whether suggestion text should be omitted from errors.
|
|
3405
|
+
* @returns The internal runtime value for the enum literal.
|
|
3406
|
+
* @example
|
|
3407
|
+
* ```ts
|
|
3408
|
+
* import { parseConstValue } from 'graphql/language';
|
|
3409
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3410
|
+
*
|
|
3411
|
+
* const RGB = new GraphQLEnumType({
|
|
3412
|
+
* name: 'RGB',
|
|
3413
|
+
* values: {
|
|
3414
|
+
* RED: { value: 0 },
|
|
3415
|
+
* GREEN: { value: 1 },
|
|
3416
|
+
* BLUE: { value: 2 },
|
|
3417
|
+
* },
|
|
3418
|
+
* });
|
|
3419
|
+
*
|
|
3420
|
+
* RGB.coerceInputLiteral(parseConstValue('RED')); // => 0
|
|
3421
|
+
* RGB.coerceInputLiteral(parseConstValue('"RED"'), true); // throws an error
|
|
3422
|
+
* ```
|
|
3423
|
+
*/
|
|
3424
|
+
coerceInputLiteral(valueNode: ConstValueNode, hideSuggestions?: Maybe<boolean>): Maybe<any>;
|
|
3425
|
+
/**
|
|
3426
|
+
* Converts a runtime enum value to a GraphQL enum value AST node.
|
|
3427
|
+
* @param value - Runtime enum value to convert.
|
|
3428
|
+
* @returns Enum value AST node, or undefined if the value is invalid.
|
|
3429
|
+
* @example
|
|
3430
|
+
* ```ts
|
|
3431
|
+
* import { print } from 'graphql/language';
|
|
3432
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3433
|
+
*
|
|
3434
|
+
* const RGB = new GraphQLEnumType({
|
|
3435
|
+
* name: 'RGB',
|
|
3436
|
+
* values: {
|
|
3437
|
+
* RED: { value: 0 },
|
|
3438
|
+
* GREEN: { value: 1 },
|
|
3439
|
+
* BLUE: { value: 2 },
|
|
3440
|
+
* },
|
|
3441
|
+
* });
|
|
3442
|
+
*
|
|
3443
|
+
* print(RGB.valueToLiteral(2)); // => 'BLUE'
|
|
3444
|
+
* RGB.valueToLiteral(3); // => undefined
|
|
3445
|
+
* ```
|
|
3446
|
+
*/
|
|
3447
|
+
valueToLiteral(value: unknown): ConstValueNode | undefined;
|
|
3448
|
+
/**
|
|
3449
|
+
* Returns a normalized configuration object for this object.
|
|
3450
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
3451
|
+
* @example
|
|
3452
|
+
* ```ts
|
|
3453
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3454
|
+
*
|
|
3455
|
+
* const RGB = new GraphQLEnumType({
|
|
3456
|
+
* name: 'RGB',
|
|
3457
|
+
* values: {
|
|
3458
|
+
* RED: { value: 0 },
|
|
3459
|
+
* GREEN: { value: 1 },
|
|
3460
|
+
* BLUE: { value: 2 },
|
|
3461
|
+
* },
|
|
3462
|
+
* });
|
|
3463
|
+
*
|
|
3464
|
+
* const config = RGB.toConfig();
|
|
3465
|
+
* const RGBCopy = new GraphQLEnumType(config);
|
|
3466
|
+
*
|
|
3467
|
+
* config.values.GREEN.value; // => 1
|
|
3468
|
+
* RGBCopy.coerceOutputValue(2); // => 'BLUE'
|
|
3469
|
+
* ```
|
|
3470
|
+
*/
|
|
3471
|
+
toConfig(): GraphQLEnumTypeNormalizedConfig;
|
|
3472
|
+
/**
|
|
3473
|
+
* Returns the schema coordinate identifying this enum type.
|
|
3474
|
+
* @returns The schema coordinate for this enum type.
|
|
3475
|
+
* @example
|
|
3476
|
+
* ```ts
|
|
3477
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3478
|
+
* import { assertEnumType } from 'graphql/type';
|
|
3479
|
+
*
|
|
3480
|
+
* const schema = buildSchema(`
|
|
3481
|
+
* enum Episode {
|
|
3482
|
+
* NEW_HOPE
|
|
3483
|
+
* }
|
|
3484
|
+
*
|
|
3485
|
+
* type Query {
|
|
3486
|
+
* episode: Episode
|
|
3487
|
+
* }
|
|
3488
|
+
* `);
|
|
3489
|
+
*
|
|
3490
|
+
* const Episode = assertEnumType(schema.getType('Episode'));
|
|
3491
|
+
*
|
|
3492
|
+
* Episode.toString(); // => 'Episode'
|
|
3493
|
+
* ```
|
|
3494
|
+
*/
|
|
3495
|
+
toString(): string;
|
|
3496
|
+
/**
|
|
3497
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3498
|
+
* @returns The JSON-serializable representation.
|
|
3499
|
+
* @example
|
|
3500
|
+
* ```ts
|
|
3501
|
+
* import { GraphQLEnumType } from 'graphql/type';
|
|
3502
|
+
*
|
|
3503
|
+
* const Episode = new GraphQLEnumType({
|
|
3504
|
+
* name: 'Episode',
|
|
3505
|
+
* values: {
|
|
3506
|
+
* NEW_HOPE: {},
|
|
3507
|
+
* },
|
|
3508
|
+
* });
|
|
3509
|
+
*
|
|
3510
|
+
* Episode.toJSON(); // => 'Episode'
|
|
3511
|
+
* JSON.stringify({ type: Episode }); // => '{"type":"Episode"}'
|
|
3512
|
+
* ```
|
|
3513
|
+
*/
|
|
3514
|
+
toJSON(): string;
|
|
3515
|
+
}
|
|
3516
|
+
/** Configuration used to construct a GraphQLEnumType. */
|
|
3517
|
+
interface GraphQLEnumTypeConfig {
|
|
3518
|
+
/** The GraphQL name for this schema element. */
|
|
3519
|
+
name: string;
|
|
3520
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3521
|
+
description?: Maybe<string>;
|
|
3522
|
+
/** Values contained in this enum, list, or input-object definition. */
|
|
3523
|
+
values: ThunkObjMap<GraphQLEnumValueConfig>;
|
|
3524
|
+
/** Custom extension fields reserved for users. */
|
|
3525
|
+
extensions?: Maybe<Readonly<GraphQLEnumTypeExtensions>>;
|
|
3526
|
+
/** AST node from which this schema element was built, if available. */
|
|
3527
|
+
astNode?: Maybe<EnumTypeDefinitionNode>;
|
|
3528
|
+
/** AST extension nodes applied to this schema element. */
|
|
3529
|
+
extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
|
|
3530
|
+
}
|
|
3531
|
+
/** @internal */
|
|
3532
|
+
interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {
|
|
3533
|
+
values: GraphQLEnumValueNormalizedConfigMap;
|
|
3534
|
+
extensions: Readonly<GraphQLEnumTypeExtensions>;
|
|
3535
|
+
extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
|
|
3536
|
+
}
|
|
3537
|
+
/** @internal */
|
|
3538
|
+
type GraphQLEnumValueNormalizedConfigMap = ObjMap<GraphQLEnumValueNormalizedConfig>;
|
|
3539
|
+
/**
|
|
3540
|
+
* Custom extensions
|
|
3541
|
+
* @remarks
|
|
3542
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
3543
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
3544
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
3545
|
+
* an object which can contain all the values you need.
|
|
3546
|
+
*/
|
|
3547
|
+
interface GraphQLEnumValueExtensions {
|
|
3548
|
+
[attributeName: string | symbol]: unknown;
|
|
3549
|
+
}
|
|
3550
|
+
/** Configuration used to define a GraphQL enum value. */
|
|
3551
|
+
interface GraphQLEnumValueConfig {
|
|
3552
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3553
|
+
description?: Maybe<string>;
|
|
3554
|
+
/** Parsed value represented by this node. */
|
|
3555
|
+
value?: any;
|
|
3556
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
3557
|
+
deprecationReason?: Maybe<string>;
|
|
3558
|
+
/** Custom extension fields reserved for users. */
|
|
3559
|
+
extensions?: Maybe<Readonly<GraphQLEnumValueExtensions>>;
|
|
3560
|
+
/** AST node from which this schema element was built, if available. */
|
|
3561
|
+
astNode?: Maybe<EnumValueDefinitionNode>;
|
|
3562
|
+
}
|
|
3563
|
+
/** @internal */
|
|
3564
|
+
interface GraphQLEnumValueNormalizedConfig extends GraphQLEnumValueConfig {
|
|
3565
|
+
extensions: Readonly<GraphQLEnumValueExtensions>;
|
|
3566
|
+
}
|
|
3567
|
+
/** A resolved GraphQL enum value definition. */
|
|
3568
|
+
declare class GraphQLEnumValue implements GraphQLSchemaElement {
|
|
3569
|
+
/** Enum type that owns this enum value. */
|
|
3570
|
+
parentEnum: GraphQLEnumType;
|
|
3571
|
+
/** The GraphQL name for this schema element. */
|
|
3572
|
+
name: string;
|
|
3573
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3574
|
+
description: Maybe<string>;
|
|
3575
|
+
/** Parsed value represented by this node. */
|
|
3576
|
+
value: any;
|
|
3577
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
3578
|
+
deprecationReason: Maybe<string>;
|
|
3579
|
+
/** Custom extension fields reserved for users. */
|
|
3580
|
+
extensions: Readonly<GraphQLEnumValueExtensions>;
|
|
3581
|
+
/** AST node from which this schema element was built, if available. */
|
|
3582
|
+
astNode: Maybe<EnumValueDefinitionNode>;
|
|
3583
|
+
/**
|
|
3584
|
+
* Creates a resolved GraphQL enum value definition.
|
|
3585
|
+
* @param parentEnum - Enum type that owns this enum value.
|
|
3586
|
+
* @param name - Enum value name.
|
|
3587
|
+
* @param config - Enum value configuration.
|
|
3588
|
+
* @example
|
|
3589
|
+
* ```ts
|
|
3590
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3591
|
+
*
|
|
3592
|
+
* const Episode = new GraphQLEnumType({
|
|
3593
|
+
* name: 'Episode',
|
|
3594
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3595
|
+
* });
|
|
3596
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', {
|
|
3597
|
+
* value: 5,
|
|
3598
|
+
* description: 'Released in 1980.',
|
|
3599
|
+
* });
|
|
3600
|
+
*
|
|
3601
|
+
* enumValue.parentEnum; // => Episode
|
|
3602
|
+
* enumValue.name; // => 'EMPIRE'
|
|
3603
|
+
* enumValue.value; // => 5
|
|
3604
|
+
* ```
|
|
3605
|
+
*/
|
|
3606
|
+
constructor(parentEnum: GraphQLEnumType, name: string, config: GraphQLEnumValueConfig);
|
|
3607
|
+
/**
|
|
3608
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3609
|
+
* @returns The built-in string tag for this object.
|
|
3610
|
+
*/
|
|
3611
|
+
get [Symbol.toStringTag](): string;
|
|
3612
|
+
/**
|
|
3613
|
+
* Returns a normalized configuration object for this enum value.
|
|
3614
|
+
* @returns A configuration object that can be used to recreate this enum value.
|
|
3615
|
+
* @example
|
|
3616
|
+
* ```ts
|
|
3617
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3618
|
+
*
|
|
3619
|
+
* const Episode = new GraphQLEnumType({
|
|
3620
|
+
* name: 'Episode',
|
|
3621
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3622
|
+
* });
|
|
3623
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', {
|
|
3624
|
+
* value: 5,
|
|
3625
|
+
* extensions: { trilogy: 'original' },
|
|
3626
|
+
* });
|
|
3627
|
+
*
|
|
3628
|
+
* enumValue.toConfig(); // => { description: undefined, value: 5, deprecationReason: undefined, extensions: { trilogy: 'original' }, astNode: undefined }
|
|
3629
|
+
* ```
|
|
3630
|
+
*/
|
|
3631
|
+
toConfig(): GraphQLEnumValueNormalizedConfig;
|
|
3632
|
+
/**
|
|
3633
|
+
* Returns this enum value as a schema coordinate string.
|
|
3634
|
+
* @returns Enum value coordinate.
|
|
3635
|
+
* @example
|
|
3636
|
+
* ```ts
|
|
3637
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3638
|
+
*
|
|
3639
|
+
* const Episode = new GraphQLEnumType({
|
|
3640
|
+
* name: 'Episode',
|
|
3641
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3642
|
+
* });
|
|
3643
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', { value: 5 });
|
|
3644
|
+
*
|
|
3645
|
+
* enumValue.toString(); // => 'Episode.EMPIRE'
|
|
3646
|
+
* ```
|
|
3647
|
+
*/
|
|
3648
|
+
toString(): string;
|
|
3649
|
+
/**
|
|
3650
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3651
|
+
* @returns Enum value coordinate.
|
|
3652
|
+
* @example
|
|
3653
|
+
* ```ts
|
|
3654
|
+
* import { GraphQLEnumType, GraphQLEnumValue } from 'graphql/type';
|
|
3655
|
+
*
|
|
3656
|
+
* const Episode = new GraphQLEnumType({
|
|
3657
|
+
* name: 'Episode',
|
|
3658
|
+
* values: { NEW_HOPE: { value: 4 } },
|
|
3659
|
+
* });
|
|
3660
|
+
* const enumValue = new GraphQLEnumValue(Episode, 'EMPIRE', { value: 5 });
|
|
3661
|
+
*
|
|
3662
|
+
* JSON.stringify(enumValue); // => '"Episode.EMPIRE"'
|
|
3663
|
+
* ```
|
|
3664
|
+
*/
|
|
3665
|
+
toJSON(): string;
|
|
3666
|
+
}
|
|
3667
|
+
/**
|
|
3668
|
+
* Custom extensions
|
|
3669
|
+
* @remarks
|
|
3670
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
3671
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
3672
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
3673
|
+
* an object which can contain all the values you need.
|
|
3674
|
+
*/
|
|
3675
|
+
interface GraphQLInputObjectTypeExtensions {
|
|
3676
|
+
[attributeName: string | symbol]: unknown;
|
|
3677
|
+
}
|
|
3678
|
+
/**
|
|
3679
|
+
* Input Object Type Definition
|
|
3680
|
+
*
|
|
3681
|
+
* An input object defines a structured collection of fields which may be
|
|
3682
|
+
* supplied to a field argument.
|
|
3683
|
+
*
|
|
3684
|
+
* Using `NonNull` will ensure that a value must be provided by the query
|
|
3685
|
+
* @example
|
|
3686
|
+
* ```ts
|
|
3687
|
+
* const GeoPoint = new GraphQLInputObjectType({
|
|
3688
|
+
* name: 'GeoPoint',
|
|
3689
|
+
* fields: {
|
|
3690
|
+
* lat: { type: new GraphQLNonNull(GraphQLFloat) },
|
|
3691
|
+
* lon: { type: new GraphQLNonNull(GraphQLFloat) },
|
|
3692
|
+
* alt: { type: GraphQLFloat, default: { value: 0 } },
|
|
3693
|
+
* },
|
|
3694
|
+
* });
|
|
3695
|
+
* ```
|
|
3696
|
+
*/
|
|
3697
|
+
declare class GraphQLInputObjectType implements GraphQLSchemaElement {
|
|
3698
|
+
/** The GraphQL name for this schema element. */
|
|
3699
|
+
name: string;
|
|
3700
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3701
|
+
description: Maybe<string>;
|
|
3702
|
+
/** Custom extension fields reserved for users. */
|
|
3703
|
+
extensions: Readonly<GraphQLInputObjectTypeExtensions>;
|
|
3704
|
+
/** AST node from which this schema element was built, if available. */
|
|
3705
|
+
astNode: Maybe<InputObjectTypeDefinitionNode>;
|
|
3706
|
+
/** AST extension nodes applied to this schema element. */
|
|
3707
|
+
extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
|
|
3708
|
+
/** Whether this input object uses the experimental OneOf input object semantics. */
|
|
3709
|
+
isOneOf: boolean;
|
|
3710
|
+
private _fields;
|
|
3711
|
+
/**
|
|
3712
|
+
* Creates a GraphQLInputObjectType instance.
|
|
3713
|
+
* @param config - Configuration describing this object.
|
|
3714
|
+
* @example
|
|
3715
|
+
* ```ts
|
|
3716
|
+
* import { parse } from 'graphql/language';
|
|
3717
|
+
* import {
|
|
3718
|
+
* GraphQLID,
|
|
3719
|
+
* GraphQLInputObjectType,
|
|
3720
|
+
* GraphQLInt,
|
|
3721
|
+
* GraphQLNonNull,
|
|
3722
|
+
* GraphQLString,
|
|
3723
|
+
* } from 'graphql/type';
|
|
3724
|
+
*
|
|
3725
|
+
* const document = parse(`
|
|
3726
|
+
* input ReviewInput {
|
|
3727
|
+
* stars: Int!
|
|
3728
|
+
* commentary: String
|
|
3729
|
+
* }
|
|
3730
|
+
*
|
|
3731
|
+
* extend input ReviewInput {
|
|
3732
|
+
* body: String
|
|
3733
|
+
* }
|
|
3734
|
+
* `);
|
|
3735
|
+
* const definition = document.definitions[0];
|
|
3736
|
+
*
|
|
3737
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3738
|
+
* name: 'ReviewInput',
|
|
3739
|
+
* description: 'Input collected when reviewing a product.',
|
|
3740
|
+
* fields: {
|
|
3741
|
+
* stars: {
|
|
3742
|
+
* description: 'Star rating from one to five.',
|
|
3743
|
+
* type: new GraphQLNonNull(GraphQLInt),
|
|
3744
|
+
* extensions: { min: 1, max: 5 },
|
|
3745
|
+
* astNode: definition.fields[0],
|
|
3746
|
+
* },
|
|
3747
|
+
* commentary: {
|
|
3748
|
+
* type: GraphQLString,
|
|
3749
|
+
* default: { value: '' },
|
|
3750
|
+
* deprecationReason: 'Use body.',
|
|
3751
|
+
* astNode: definition.fields[1],
|
|
3752
|
+
* },
|
|
3753
|
+
* },
|
|
3754
|
+
* extensions: { form: 'review' },
|
|
3755
|
+
* astNode: definition,
|
|
3756
|
+
* extensionASTNodes: [document.definitions[1]],
|
|
3757
|
+
* isOneOf: false,
|
|
3758
|
+
* });
|
|
3759
|
+
* const SearchBy = new GraphQLInputObjectType({
|
|
3760
|
+
* name: 'SearchBy',
|
|
3761
|
+
* fields: {
|
|
3762
|
+
* id: { type: GraphQLID },
|
|
3763
|
+
* slug: { type: GraphQLString },
|
|
3764
|
+
* },
|
|
3765
|
+
* isOneOf: true,
|
|
3766
|
+
* });
|
|
3767
|
+
*
|
|
3768
|
+
* const fields = ReviewInput.getFields();
|
|
3769
|
+
*
|
|
3770
|
+
* ReviewInput.description; // => 'Input collected when reviewing a product.'
|
|
3771
|
+
* String(fields.stars.type); // => 'Int!'
|
|
3772
|
+
* fields.stars.extensions; // => { min: 1, max: 5 }
|
|
3773
|
+
* fields.commentary.default.value; // => ''
|
|
3774
|
+
* fields.commentary.deprecationReason; // => 'Use body.'
|
|
3775
|
+
* ReviewInput.isOneOf; // => false
|
|
3776
|
+
* SearchBy.isOneOf; // => true
|
|
3777
|
+
* ```
|
|
3778
|
+
*/
|
|
3779
|
+
constructor(config: Readonly<GraphQLInputObjectTypeConfig>);
|
|
3780
|
+
/**
|
|
3781
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3782
|
+
* @returns The built-in string tag for this object.
|
|
3783
|
+
*/
|
|
3784
|
+
get [Symbol.toStringTag](): string;
|
|
3785
|
+
/**
|
|
3786
|
+
* Returns the fields defined by this type.
|
|
3787
|
+
* @returns The fields keyed by field name.
|
|
3788
|
+
* @example
|
|
3789
|
+
* ```ts
|
|
3790
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3791
|
+
* import { assertInputObjectType } from 'graphql/type';
|
|
3792
|
+
*
|
|
3793
|
+
* const schema = buildSchema(`
|
|
3794
|
+
* input ReviewInput {
|
|
3795
|
+
* stars: Int!
|
|
3796
|
+
* commentary: String = ""
|
|
3797
|
+
* }
|
|
3798
|
+
*
|
|
3799
|
+
* type Query {
|
|
3800
|
+
* reviews(filter: ReviewInput): [String]
|
|
3801
|
+
* }
|
|
3802
|
+
* `);
|
|
3803
|
+
*
|
|
3804
|
+
* const ReviewInput = assertInputObjectType(schema.getType('ReviewInput'));
|
|
3805
|
+
* const fields = ReviewInput.getFields();
|
|
3806
|
+
*
|
|
3807
|
+
* Object.keys(fields); // => ['stars', 'commentary']
|
|
3808
|
+
* fields.commentary.default; // => { literal: { kind: 'StringValue', value: '' } }
|
|
3809
|
+
* ```
|
|
3810
|
+
*/
|
|
3811
|
+
getFields(): GraphQLInputFieldMap;
|
|
3812
|
+
/**
|
|
3813
|
+
* Returns a normalized configuration object for this object.
|
|
3814
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
3815
|
+
* @example
|
|
3816
|
+
* ```ts
|
|
3817
|
+
* import {
|
|
3818
|
+
* GraphQLInputObjectType,
|
|
3819
|
+
* GraphQLInt,
|
|
3820
|
+
* GraphQLNonNull,
|
|
3821
|
+
* } from 'graphql/type';
|
|
3822
|
+
*
|
|
3823
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3824
|
+
* name: 'ReviewInput',
|
|
3825
|
+
* fields: {
|
|
3826
|
+
* stars: { type: new GraphQLNonNull(GraphQLInt) },
|
|
3827
|
+
* },
|
|
3828
|
+
* });
|
|
3829
|
+
*
|
|
3830
|
+
* const config = ReviewInput.toConfig();
|
|
3831
|
+
* const ReviewInputCopy = new GraphQLInputObjectType(config);
|
|
3832
|
+
*
|
|
3833
|
+
* String(config.fields.stars.type); // => 'Int!'
|
|
3834
|
+
* String(ReviewInputCopy.getFields().stars.type); // => 'Int!'
|
|
3835
|
+
* ```
|
|
3836
|
+
*/
|
|
3837
|
+
toConfig(): GraphQLInputObjectTypeNormalizedConfig;
|
|
3838
|
+
/**
|
|
3839
|
+
* Returns the schema coordinate identifying this input object type.
|
|
3840
|
+
* @returns The schema coordinate for this input object type.
|
|
3841
|
+
* @example
|
|
3842
|
+
* ```ts
|
|
3843
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
3844
|
+
* import { assertInputObjectType } from 'graphql/type';
|
|
3845
|
+
*
|
|
3846
|
+
* const schema = buildSchema(`
|
|
3847
|
+
* input ReviewInput {
|
|
3848
|
+
* stars: Int!
|
|
3849
|
+
* }
|
|
3850
|
+
*
|
|
3851
|
+
* type Query {
|
|
3852
|
+
* reviews(filter: ReviewInput): [String]
|
|
3853
|
+
* }
|
|
3854
|
+
* `);
|
|
3855
|
+
*
|
|
3856
|
+
* const ReviewInput = assertInputObjectType(schema.getType('ReviewInput'));
|
|
3857
|
+
*
|
|
3858
|
+
* ReviewInput.toString(); // => 'ReviewInput'
|
|
3859
|
+
* ```
|
|
3860
|
+
*/
|
|
3861
|
+
toString(): string;
|
|
3862
|
+
/**
|
|
3863
|
+
* Returns the JSON representation used when this object is serialized.
|
|
3864
|
+
* @returns The JSON-serializable representation.
|
|
3865
|
+
* @example
|
|
3866
|
+
* ```ts
|
|
3867
|
+
* import { GraphQLInputObjectType, GraphQLString } from 'graphql/type';
|
|
3868
|
+
*
|
|
3869
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3870
|
+
* name: 'ReviewInput',
|
|
3871
|
+
* fields: {
|
|
3872
|
+
* commentary: { type: GraphQLString },
|
|
3873
|
+
* },
|
|
3874
|
+
* });
|
|
3875
|
+
*
|
|
3876
|
+
* ReviewInput.toJSON(); // => 'ReviewInput'
|
|
3877
|
+
* JSON.stringify({ type: ReviewInput }); // => '{"type":"ReviewInput"}'
|
|
3878
|
+
* ```
|
|
3879
|
+
*/
|
|
3880
|
+
toJSON(): string;
|
|
3881
|
+
}
|
|
3882
|
+
/** Configuration used to construct a GraphQLInputObjectType. */
|
|
3883
|
+
interface GraphQLInputObjectTypeConfig {
|
|
3884
|
+
/** The GraphQL name for this schema element. */
|
|
3885
|
+
name: string;
|
|
3886
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3887
|
+
description?: Maybe<string>;
|
|
3888
|
+
/** Fields declared by this object, interface, input object, or literal. */
|
|
3889
|
+
fields: ThunkObjMap<GraphQLInputFieldConfig>;
|
|
3890
|
+
/** Custom extension fields reserved for users. */
|
|
3891
|
+
extensions?: Maybe<Readonly<GraphQLInputObjectTypeExtensions>>;
|
|
3892
|
+
/** AST node from which this schema element was built, if available. */
|
|
3893
|
+
astNode?: Maybe<InputObjectTypeDefinitionNode>;
|
|
3894
|
+
/** AST extension nodes applied to this schema element. */
|
|
3895
|
+
extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
|
|
3896
|
+
/** Whether this input object uses the experimental OneOf input object semantics. */
|
|
3897
|
+
isOneOf?: boolean;
|
|
3898
|
+
}
|
|
3899
|
+
/** @internal */
|
|
3900
|
+
interface GraphQLInputObjectTypeNormalizedConfig extends GraphQLInputObjectTypeConfig {
|
|
3901
|
+
fields: GraphQLInputFieldNormalizedConfigMap;
|
|
3902
|
+
extensions: Readonly<GraphQLInputObjectTypeExtensions>;
|
|
3903
|
+
extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
|
|
3904
|
+
}
|
|
3905
|
+
/**
|
|
3906
|
+
* Custom extensions
|
|
3907
|
+
* @remarks
|
|
3908
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
3909
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
3910
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
3911
|
+
* an object which can contain all the values you need.
|
|
3912
|
+
*/
|
|
3913
|
+
interface GraphQLInputFieldExtensions {
|
|
3914
|
+
[attributeName: string | symbol]: unknown;
|
|
3915
|
+
}
|
|
3916
|
+
/** Configuration used to define a GraphQL input field. */
|
|
3917
|
+
interface GraphQLInputFieldConfig {
|
|
3918
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3919
|
+
description?: Maybe<string>;
|
|
3920
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
3921
|
+
type: GraphQLInputType;
|
|
3922
|
+
/**
|
|
3923
|
+
* Deprecated legacy default value for this input field. Use `default`
|
|
3924
|
+
* instead.
|
|
3925
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
3926
|
+
*/
|
|
3927
|
+
defaultValue?: unknown;
|
|
3928
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
3929
|
+
default?: GraphQLDefaultInput | undefined;
|
|
3930
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
3931
|
+
deprecationReason?: Maybe<string>;
|
|
3932
|
+
/** Custom extension fields reserved for users. */
|
|
3933
|
+
extensions?: Maybe<Readonly<GraphQLInputFieldExtensions>>;
|
|
3934
|
+
/** AST node from which this schema element was built, if available. */
|
|
3935
|
+
astNode?: Maybe<InputValueDefinitionNode>;
|
|
3936
|
+
}
|
|
3937
|
+
/** @internal */
|
|
3938
|
+
interface GraphQLInputFieldNormalizedConfig extends GraphQLInputFieldConfig {
|
|
3939
|
+
default: GraphQLDefaultInput | undefined;
|
|
3940
|
+
extensions: Readonly<GraphQLInputFieldExtensions>;
|
|
3941
|
+
}
|
|
3942
|
+
/** @internal */
|
|
3943
|
+
type GraphQLInputFieldNormalizedConfigMap = ObjMap<GraphQLInputFieldNormalizedConfig>;
|
|
3944
|
+
/** A resolved GraphQL input field definition. */
|
|
3945
|
+
declare class GraphQLInputField implements GraphQLSchemaElement {
|
|
3946
|
+
/** Input object type that owns this input field. */
|
|
3947
|
+
parentType: GraphQLInputObjectType;
|
|
3948
|
+
/** The GraphQL name for this schema element. */
|
|
3949
|
+
name: string;
|
|
3950
|
+
/** Human-readable description for this schema element, if provided. */
|
|
3951
|
+
description: Maybe<string>;
|
|
3952
|
+
/** The GraphQL type reference or runtime type for this element. */
|
|
3953
|
+
type: GraphQLInputType;
|
|
3954
|
+
/**
|
|
3955
|
+
* Deprecated legacy default value used when no explicit value is supplied.
|
|
3956
|
+
* Use `default` instead.
|
|
3957
|
+
* @deprecated use `default` instead, `defaultValue` will be removed in v18
|
|
3958
|
+
*/
|
|
3959
|
+
defaultValue: unknown;
|
|
3960
|
+
/** Default value represented as either a runtime value or a GraphQL literal. */
|
|
3961
|
+
default: GraphQLDefaultInput | undefined;
|
|
3962
|
+
/** Reason this element is deprecated, if one was provided. */
|
|
3963
|
+
deprecationReason: Maybe<string>;
|
|
3964
|
+
/** Custom extension fields reserved for users. */
|
|
3965
|
+
extensions: Readonly<GraphQLInputFieldExtensions>;
|
|
3966
|
+
/** AST node from which this schema element was built, if available. */
|
|
3967
|
+
astNode: Maybe<InputValueDefinitionNode>;
|
|
3968
|
+
/**
|
|
3969
|
+
* Creates a resolved GraphQL input field definition.
|
|
3970
|
+
* @param parentType - Input object type that owns this field.
|
|
3971
|
+
* @param name - Input field name.
|
|
3972
|
+
* @param config - Input field configuration.
|
|
3973
|
+
* @example
|
|
3974
|
+
* ```ts
|
|
3975
|
+
* import {
|
|
3976
|
+
* GraphQLInputField,
|
|
3977
|
+
* GraphQLInputObjectType,
|
|
3978
|
+
* GraphQLString,
|
|
3979
|
+
* } from 'graphql/type';
|
|
3980
|
+
*
|
|
3981
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
3982
|
+
* name: 'ReviewInput',
|
|
3983
|
+
* fields: {},
|
|
3984
|
+
* });
|
|
3985
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
3986
|
+
* type: GraphQLString,
|
|
3987
|
+
* default: { value: '' },
|
|
3988
|
+
* });
|
|
3989
|
+
*
|
|
3990
|
+
* field.parentType; // => ReviewInput
|
|
3991
|
+
* field.name; // => 'commentary'
|
|
3992
|
+
* field.default.value; // => ''
|
|
3993
|
+
* ```
|
|
3994
|
+
*/
|
|
3995
|
+
constructor(parentType: GraphQLInputObjectType, name: string, config: GraphQLInputFieldConfig);
|
|
3996
|
+
/**
|
|
3997
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
3998
|
+
* @returns The built-in string tag for this object.
|
|
3999
|
+
*/
|
|
4000
|
+
get [Symbol.toStringTag](): string;
|
|
4001
|
+
/**
|
|
4002
|
+
* Returns a normalized configuration object for this input field.
|
|
4003
|
+
* @returns A configuration object that can be used to recreate this input field.
|
|
4004
|
+
* @example
|
|
4005
|
+
* ```ts
|
|
4006
|
+
* import {
|
|
4007
|
+
* GraphQLInputField,
|
|
4008
|
+
* GraphQLInputObjectType,
|
|
4009
|
+
* GraphQLString,
|
|
4010
|
+
* } from 'graphql/type';
|
|
4011
|
+
*
|
|
4012
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
4013
|
+
* name: 'ReviewInput',
|
|
4014
|
+
* fields: {},
|
|
4015
|
+
* });
|
|
4016
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
4017
|
+
* type: GraphQLString,
|
|
4018
|
+
* extensions: { form: 'review' },
|
|
4019
|
+
* });
|
|
4020
|
+
*
|
|
4021
|
+
* field.toConfig().extensions; // => { form: 'review' }
|
|
4022
|
+
* ```
|
|
4023
|
+
*/
|
|
4024
|
+
toConfig(): GraphQLInputFieldNormalizedConfig;
|
|
4025
|
+
/**
|
|
4026
|
+
* Returns this input field as a schema coordinate string.
|
|
4027
|
+
* @returns The input field coordinate.
|
|
4028
|
+
* @example
|
|
4029
|
+
* ```ts
|
|
4030
|
+
* import {
|
|
4031
|
+
* GraphQLInputField,
|
|
4032
|
+
* GraphQLInputObjectType,
|
|
4033
|
+
* GraphQLString,
|
|
4034
|
+
* } from 'graphql/type';
|
|
4035
|
+
*
|
|
4036
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
4037
|
+
* name: 'ReviewInput',
|
|
4038
|
+
* fields: {},
|
|
4039
|
+
* });
|
|
4040
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
4041
|
+
* type: GraphQLString,
|
|
4042
|
+
* });
|
|
4043
|
+
*
|
|
4044
|
+
* field.toString(); // => 'ReviewInput.commentary'
|
|
4045
|
+
* ```
|
|
4046
|
+
*/
|
|
4047
|
+
toString(): string;
|
|
4048
|
+
/**
|
|
4049
|
+
* Returns the JSON representation used when this object is serialized.
|
|
4050
|
+
* @returns The input field coordinate.
|
|
4051
|
+
* @example
|
|
4052
|
+
* ```ts
|
|
4053
|
+
* import {
|
|
4054
|
+
* GraphQLInputField,
|
|
4055
|
+
* GraphQLInputObjectType,
|
|
4056
|
+
* GraphQLString,
|
|
4057
|
+
* } from 'graphql/type';
|
|
4058
|
+
*
|
|
4059
|
+
* const ReviewInput = new GraphQLInputObjectType({
|
|
4060
|
+
* name: 'ReviewInput',
|
|
4061
|
+
* fields: {},
|
|
4062
|
+
* });
|
|
4063
|
+
* const field = new GraphQLInputField(ReviewInput, 'commentary', {
|
|
4064
|
+
* type: GraphQLString,
|
|
4065
|
+
* });
|
|
4066
|
+
*
|
|
4067
|
+
* JSON.stringify(field); // => '"ReviewInput.commentary"'
|
|
4068
|
+
* ```
|
|
4069
|
+
*/
|
|
4070
|
+
toJSON(): string;
|
|
4071
|
+
}
|
|
4072
|
+
/** A map of input field names to resolved input field definitions. */
|
|
4073
|
+
type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;
|
|
4074
|
+
//#endregion
|
|
4075
|
+
//#region ../../../node_modules/.pnpm/graphql@17.0.2/node_modules/graphql/type/schema.d.ts
|
|
4076
|
+
/**
|
|
4077
|
+
* Custom extensions
|
|
4078
|
+
* @remarks
|
|
4079
|
+
* Use a unique identifier name for your extension, for example the name of
|
|
4080
|
+
* your library or project. Do not use a shortened identifier as this increases
|
|
4081
|
+
* the risk of conflicts. We recommend you add at most one extension field,
|
|
4082
|
+
* an object which can contain all the values you need.
|
|
4083
|
+
*/
|
|
4084
|
+
interface GraphQLSchemaExtensions {
|
|
4085
|
+
[attributeName: string | symbol]: unknown;
|
|
4086
|
+
}
|
|
4087
|
+
/**
|
|
4088
|
+
* Schema Definition
|
|
4089
|
+
*
|
|
4090
|
+
* A Schema is created by supplying the root types of each type of operation,
|
|
4091
|
+
* query and mutation (optional). A schema definition is then supplied to the
|
|
4092
|
+
* validator and executor.
|
|
4093
|
+
* @example
|
|
4094
|
+
* ```ts
|
|
4095
|
+
* const MyAppQueryRootType = new GraphQLObjectType({
|
|
4096
|
+
* name: 'Query',
|
|
4097
|
+
* fields: {
|
|
4098
|
+
* greeting: { type: GraphQLString },
|
|
4099
|
+
* },
|
|
4100
|
+
* });
|
|
4101
|
+
*
|
|
4102
|
+
* const MyAppMutationRootType = new GraphQLObjectType({
|
|
4103
|
+
* name: 'Mutation',
|
|
4104
|
+
* fields: {
|
|
4105
|
+
* setGreeting: { type: GraphQLString },
|
|
4106
|
+
* },
|
|
4107
|
+
* });
|
|
4108
|
+
*
|
|
4109
|
+
* const MyAppSchema = new GraphQLSchema({
|
|
4110
|
+
* query: MyAppQueryRootType,
|
|
4111
|
+
* mutation: MyAppMutationRootType,
|
|
4112
|
+
* });
|
|
4113
|
+
* ```
|
|
4114
|
+
* @example
|
|
4115
|
+
* When the schema is constructed, by default only the types that are reachable
|
|
4116
|
+
* by traversing the root types are included, other types must be explicitly
|
|
4117
|
+
* referenced.
|
|
4118
|
+
*
|
|
4119
|
+
* ```ts
|
|
4120
|
+
* const characterInterface = new GraphQLInterfaceType({
|
|
4121
|
+
* name: 'Character',
|
|
4122
|
+
* fields: {
|
|
4123
|
+
* name: { type: GraphQLString },
|
|
4124
|
+
* },
|
|
4125
|
+
* });
|
|
4126
|
+
*
|
|
4127
|
+
* const humanType = new GraphQLObjectType({
|
|
4128
|
+
* name: 'Human',
|
|
4129
|
+
* interfaces: [characterInterface],
|
|
4130
|
+
* fields: {
|
|
4131
|
+
* name: { type: GraphQLString },
|
|
4132
|
+
* },
|
|
4133
|
+
* });
|
|
4134
|
+
*
|
|
4135
|
+
* const droidType = new GraphQLObjectType({
|
|
4136
|
+
* name: 'Droid',
|
|
4137
|
+
* interfaces: [characterInterface],
|
|
4138
|
+
* fields: {
|
|
4139
|
+
* name: { type: GraphQLString },
|
|
4140
|
+
* },
|
|
4141
|
+
* });
|
|
4142
|
+
*
|
|
4143
|
+
* const schema = new GraphQLSchema({
|
|
4144
|
+
* query: new GraphQLObjectType({
|
|
4145
|
+
* name: 'Query',
|
|
4146
|
+
* fields: {
|
|
4147
|
+
* hero: { type: characterInterface },
|
|
4148
|
+
* },
|
|
4149
|
+
* }),
|
|
4150
|
+
* // Since this schema references only the `Character` interface it's
|
|
4151
|
+
* // necessary to explicitly list the types that implement it if
|
|
4152
|
+
* // you want them to be included in the final schema.
|
|
4153
|
+
* types: [humanType, droidType],
|
|
4154
|
+
* });
|
|
4155
|
+
* ```
|
|
4156
|
+
* @example
|
|
4157
|
+
* If an array of `directives` are provided to GraphQLSchema, that will be the
|
|
4158
|
+
* exact list of directives represented and allowed. If `directives` is not
|
|
4159
|
+
* provided then a default set of the specified directives (e.g. `@include` and
|
|
4160
|
+
* `@skip`) will be used. If you wish to provide *additional* directives to
|
|
4161
|
+
* these specified directives, you must explicitly declare them.
|
|
4162
|
+
*
|
|
4163
|
+
* ```ts
|
|
4164
|
+
* const MyAppSchema = new GraphQLSchema({
|
|
4165
|
+
* query: MyAppQueryRootType,
|
|
4166
|
+
* directives: specifiedDirectives.concat([myCustomDirective]),
|
|
4167
|
+
* });
|
|
4168
|
+
* ```
|
|
4169
|
+
*/
|
|
4170
|
+
declare class GraphQLSchema {
|
|
4171
|
+
/** Human-readable description for this schema element, if provided. */
|
|
4172
|
+
description: Maybe<string>;
|
|
4173
|
+
/** Custom extension fields reserved for users. */
|
|
4174
|
+
extensions: Readonly<GraphQLSchemaExtensions>;
|
|
4175
|
+
/** AST node from which this schema element was built, if available. */
|
|
4176
|
+
astNode: Maybe<SchemaDefinitionNode>;
|
|
4177
|
+
/** AST extension nodes applied to this schema element. */
|
|
4178
|
+
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
|
|
4179
|
+
/** Whether this schema instance skips validation checks. */
|
|
4180
|
+
assumeValid: boolean;
|
|
4181
|
+
private _queryType;
|
|
4182
|
+
private _mutationType;
|
|
4183
|
+
private _subscriptionType;
|
|
4184
|
+
private _directives;
|
|
4185
|
+
private _typeMap;
|
|
4186
|
+
private _subTypeMap;
|
|
4187
|
+
private _implementationsMap;
|
|
4188
|
+
/**
|
|
4189
|
+
* Creates a GraphQLSchema instance.
|
|
4190
|
+
* @param config - Configuration describing this object.
|
|
4191
|
+
* @example
|
|
4192
|
+
* ```ts
|
|
4193
|
+
* // Create a schema with the required query root.
|
|
4194
|
+
* import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql/type';
|
|
4195
|
+
*
|
|
4196
|
+
* const Query = new GraphQLObjectType({
|
|
4197
|
+
* name: 'Query',
|
|
4198
|
+
* fields: {
|
|
4199
|
+
* greeting: {
|
|
4200
|
+
* type: GraphQLString,
|
|
4201
|
+
* resolve: () => 'Hello',
|
|
4202
|
+
* },
|
|
4203
|
+
* },
|
|
4204
|
+
* });
|
|
4205
|
+
*
|
|
4206
|
+
* const schema = new GraphQLSchema({
|
|
4207
|
+
* description: 'The application schema.',
|
|
4208
|
+
* query: Query,
|
|
4209
|
+
* });
|
|
4210
|
+
*
|
|
4211
|
+
* schema.getQueryType(); // => Query
|
|
4212
|
+
* schema.description; // => 'The application schema.'
|
|
4213
|
+
* ```
|
|
4214
|
+
* @example
|
|
4215
|
+
* ```ts
|
|
4216
|
+
* // This variant configures every schema option, including directives and extensions.
|
|
4217
|
+
* import { DirectiveLocation, parse } from 'graphql/language';
|
|
4218
|
+
* import {
|
|
4219
|
+
* GraphQLBoolean,
|
|
4220
|
+
* GraphQLDirective,
|
|
4221
|
+
* GraphQLObjectType,
|
|
4222
|
+
* GraphQLSchema,
|
|
4223
|
+
* GraphQLString,
|
|
4224
|
+
* } from 'graphql/type';
|
|
4225
|
+
*
|
|
4226
|
+
* const Query = new GraphQLObjectType({
|
|
4227
|
+
* name: 'Query',
|
|
4228
|
+
* fields: { greeting: { type: GraphQLString } },
|
|
4229
|
+
* });
|
|
4230
|
+
* const Mutation = new GraphQLObjectType({
|
|
4231
|
+
* name: 'Mutation',
|
|
4232
|
+
* fields: { setGreeting: { type: GraphQLString } },
|
|
4233
|
+
* });
|
|
4234
|
+
* const Subscription = new GraphQLObjectType({
|
|
4235
|
+
* name: 'Subscription',
|
|
4236
|
+
* fields: { greetingChanged: { type: GraphQLString } },
|
|
4237
|
+
* });
|
|
4238
|
+
* const AuditEvent = new GraphQLObjectType({
|
|
4239
|
+
* name: 'AuditEvent',
|
|
4240
|
+
* fields: { message: { type: GraphQLString } },
|
|
4241
|
+
* });
|
|
4242
|
+
* const authDirective = new GraphQLDirective({
|
|
4243
|
+
* name: 'auth',
|
|
4244
|
+
* locations: [DirectiveLocation.FIELD_DEFINITION],
|
|
4245
|
+
* args: { required: { type: GraphQLBoolean } },
|
|
4246
|
+
* });
|
|
4247
|
+
* const schemaDocument = parse(`
|
|
4248
|
+
* schema {
|
|
4249
|
+
* query: Query
|
|
4250
|
+
* mutation: Mutation
|
|
4251
|
+
* subscription: Subscription
|
|
4252
|
+
* }
|
|
4253
|
+
*
|
|
4254
|
+
* extend schema @auth
|
|
4255
|
+
* `);
|
|
4256
|
+
*
|
|
4257
|
+
* const schema = new GraphQLSchema({
|
|
4258
|
+
* description: 'Operations exposed by the application.',
|
|
4259
|
+
* query: Query,
|
|
4260
|
+
* mutation: Mutation,
|
|
4261
|
+
* subscription: Subscription,
|
|
4262
|
+
* types: [AuditEvent],
|
|
4263
|
+
* directives: [authDirective],
|
|
4264
|
+
* extensions: { owner: 'platform' },
|
|
4265
|
+
* astNode: schemaDocument.definitions[0],
|
|
4266
|
+
* extensionASTNodes: [schemaDocument.definitions[1]],
|
|
4267
|
+
* assumeValid: true,
|
|
4268
|
+
* });
|
|
4269
|
+
*
|
|
4270
|
+
* schema.getMutationType(); // => Mutation
|
|
4271
|
+
* schema.getSubscriptionType(); // => Subscription
|
|
4272
|
+
* schema.getType('AuditEvent'); // => AuditEvent
|
|
4273
|
+
* schema.getDirective('auth'); // => authDirective
|
|
4274
|
+
* schema.extensions; // => { owner: 'platform' }
|
|
4275
|
+
* ```
|
|
4276
|
+
*/
|
|
4277
|
+
constructor(config: Readonly<GraphQLSchemaConfig>);
|
|
4278
|
+
/**
|
|
4279
|
+
* Returns the value used by `Object.prototype.toString`.
|
|
4280
|
+
* @returns The built-in string tag for this object.
|
|
4281
|
+
*/
|
|
4282
|
+
get [Symbol.toStringTag](): string;
|
|
4283
|
+
/**
|
|
4284
|
+
* Returns the root object type for query operations.
|
|
4285
|
+
* @returns The query root type, if this schema defines one.
|
|
4286
|
+
* @example
|
|
4287
|
+
* ```ts
|
|
4288
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4289
|
+
*
|
|
4290
|
+
* const schema = buildSchema(`
|
|
4291
|
+
* type Query {
|
|
4292
|
+
* greeting: String
|
|
4293
|
+
* }
|
|
4294
|
+
* `);
|
|
4295
|
+
*
|
|
4296
|
+
* schema.getQueryType()?.name; // => 'Query'
|
|
4297
|
+
* ```
|
|
4298
|
+
*/
|
|
4299
|
+
getQueryType(): Maybe<GraphQLObjectType>;
|
|
4300
|
+
/**
|
|
4301
|
+
* Returns the root object type for mutation operations.
|
|
4302
|
+
* @returns The mutation root type, if this schema defines one.
|
|
4303
|
+
* @example
|
|
4304
|
+
* ```ts
|
|
4305
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4306
|
+
*
|
|
4307
|
+
* const schema = buildSchema(`
|
|
4308
|
+
* type Query {
|
|
4309
|
+
* greeting: String
|
|
4310
|
+
* }
|
|
4311
|
+
*
|
|
4312
|
+
* type Mutation {
|
|
4313
|
+
* setGreeting(value: String!): String
|
|
4314
|
+
* }
|
|
4315
|
+
* `);
|
|
4316
|
+
*
|
|
4317
|
+
* schema.getMutationType()?.name; // => 'Mutation'
|
|
4318
|
+
* ```
|
|
4319
|
+
*/
|
|
4320
|
+
getMutationType(): Maybe<GraphQLObjectType>;
|
|
4321
|
+
/**
|
|
4322
|
+
* Returns the root object type for subscription operations.
|
|
4323
|
+
* @returns The subscription root type, if this schema defines one.
|
|
4324
|
+
* @example
|
|
4325
|
+
* ```ts
|
|
4326
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4327
|
+
*
|
|
4328
|
+
* const schema = buildSchema(`
|
|
4329
|
+
* type Query {
|
|
4330
|
+
* greeting: String
|
|
4331
|
+
* }
|
|
4332
|
+
*
|
|
4333
|
+
* type Subscription {
|
|
4334
|
+
* greetings: String
|
|
4335
|
+
* }
|
|
4336
|
+
* `);
|
|
4337
|
+
*
|
|
4338
|
+
* schema.getSubscriptionType()?.name; // => 'Subscription'
|
|
4339
|
+
* ```
|
|
4340
|
+
*/
|
|
4341
|
+
getSubscriptionType(): Maybe<GraphQLObjectType>;
|
|
4342
|
+
/**
|
|
4343
|
+
* Returns the root object type for the requested operation kind.
|
|
4344
|
+
* @param operation - Operation kind to resolve.
|
|
4345
|
+
* @returns The root object type for the operation kind, if this schema defines one.
|
|
4346
|
+
* @example
|
|
4347
|
+
* ```ts
|
|
4348
|
+
* import { OperationTypeNode } from 'graphql/language';
|
|
4349
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4350
|
+
*
|
|
4351
|
+
* const schema = buildSchema(`
|
|
4352
|
+
* type Query {
|
|
4353
|
+
* greeting: String
|
|
4354
|
+
* }
|
|
4355
|
+
*
|
|
4356
|
+
* type Mutation {
|
|
4357
|
+
* setGreeting(value: String!): String
|
|
4358
|
+
* }
|
|
4359
|
+
* `);
|
|
4360
|
+
*
|
|
4361
|
+
* schema.getRootType(OperationTypeNode.QUERY)?.name; // => 'Query'
|
|
4362
|
+
* schema.getRootType(OperationTypeNode.MUTATION)?.name; // => 'Mutation'
|
|
4363
|
+
* schema.getRootType(OperationTypeNode.SUBSCRIPTION); // => undefined
|
|
4364
|
+
* ```
|
|
4365
|
+
*/
|
|
4366
|
+
getRootType(operation: OperationTypeNode): Maybe<GraphQLObjectType>;
|
|
4367
|
+
/**
|
|
4368
|
+
* Returns all named types known to this schema.
|
|
4369
|
+
* @returns A map of schema types keyed by type name.
|
|
4370
|
+
* @example
|
|
4371
|
+
* ```ts
|
|
4372
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4373
|
+
*
|
|
4374
|
+
* const schema = buildSchema(`
|
|
4375
|
+
* type User {
|
|
4376
|
+
* name: String
|
|
4377
|
+
* }
|
|
4378
|
+
*
|
|
4379
|
+
* type Query {
|
|
4380
|
+
* viewer: User
|
|
4381
|
+
* }
|
|
4382
|
+
* `);
|
|
4383
|
+
*
|
|
4384
|
+
* const typeMap = schema.getTypeMap();
|
|
4385
|
+
*
|
|
4386
|
+
* typeMap.User.name; // => 'User'
|
|
4387
|
+
* typeMap.Query.name; // => 'Query'
|
|
4388
|
+
* typeMap.String.name; // => 'String'
|
|
4389
|
+
* ```
|
|
4390
|
+
*/
|
|
4391
|
+
getTypeMap(): TypeMap;
|
|
4392
|
+
/**
|
|
4393
|
+
* Returns the named type with the provided name.
|
|
4394
|
+
* @param name - The GraphQL name to look up.
|
|
4395
|
+
* @returns The named schema type, if one exists.
|
|
4396
|
+
* @example
|
|
4397
|
+
* ```ts
|
|
4398
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4399
|
+
*
|
|
4400
|
+
* const schema = buildSchema(`
|
|
4401
|
+
* type User {
|
|
4402
|
+
* name: String
|
|
4403
|
+
* }
|
|
4404
|
+
*
|
|
4405
|
+
* type Query {
|
|
4406
|
+
* viewer: User
|
|
4407
|
+
* }
|
|
4408
|
+
* `);
|
|
4409
|
+
*
|
|
4410
|
+
* schema.getType('User')?.toString(); // => 'User'
|
|
4411
|
+
* schema.getType('Missing'); // => undefined
|
|
4412
|
+
* ```
|
|
4413
|
+
*/
|
|
4414
|
+
getType(name: string): GraphQLNamedType | undefined;
|
|
4415
|
+
/**
|
|
4416
|
+
* Returns object types that may be returned for an abstract type.
|
|
4417
|
+
* @param abstractType - Interface or union type to inspect.
|
|
4418
|
+
* @returns Object types that may satisfy the abstract type.
|
|
4419
|
+
* @example
|
|
4420
|
+
* ```ts
|
|
4421
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4422
|
+
* import { assertInterfaceType, assertUnionType } from 'graphql/type';
|
|
4423
|
+
*
|
|
4424
|
+
* const schema = buildSchema(`
|
|
4425
|
+
* interface Node {
|
|
4426
|
+
* id: ID!
|
|
4427
|
+
* }
|
|
4428
|
+
*
|
|
4429
|
+
* type User implements Node {
|
|
4430
|
+
* id: ID!
|
|
4431
|
+
* }
|
|
4432
|
+
*
|
|
4433
|
+
* type Organization implements Node {
|
|
4434
|
+
* id: ID!
|
|
4435
|
+
* }
|
|
4436
|
+
*
|
|
4437
|
+
* union SearchResult = User | Organization
|
|
4438
|
+
*
|
|
4439
|
+
* type Query {
|
|
4440
|
+
* node: Node
|
|
4441
|
+
* search: [SearchResult]
|
|
4442
|
+
* }
|
|
4443
|
+
* `);
|
|
4444
|
+
*
|
|
4445
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
4446
|
+
* const SearchResult = assertUnionType(schema.getType('SearchResult'));
|
|
4447
|
+
*
|
|
4448
|
+
* schema.getPossibleTypes(Node).map((type) => type.name); // => ['User', 'Organization']
|
|
4449
|
+
* schema.getPossibleTypes(SearchResult).map((type) => type.name); // => ['User', 'Organization']
|
|
4450
|
+
* ```
|
|
4451
|
+
*/
|
|
4452
|
+
getPossibleTypes(abstractType: GraphQLAbstractType): ReadonlyArray<GraphQLObjectType>;
|
|
4453
|
+
/**
|
|
4454
|
+
* Returns objects and interfaces that implement an interface type.
|
|
4455
|
+
* @param interfaceType - Interface type to inspect.
|
|
4456
|
+
* @returns Object and interface implementations of the interface.
|
|
4457
|
+
* @example
|
|
4458
|
+
* ```ts
|
|
4459
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4460
|
+
* import { assertInterfaceType } from 'graphql/type';
|
|
4461
|
+
*
|
|
4462
|
+
* const schema = buildSchema(`
|
|
4463
|
+
* interface Resource {
|
|
4464
|
+
* url: String!
|
|
4465
|
+
* }
|
|
4466
|
+
*
|
|
4467
|
+
* interface Image implements Resource {
|
|
4468
|
+
* url: String!
|
|
4469
|
+
* width: Int
|
|
4470
|
+
* }
|
|
4471
|
+
*
|
|
4472
|
+
* type Photo implements Resource & Image {
|
|
4473
|
+
* url: String!
|
|
4474
|
+
* width: Int
|
|
4475
|
+
* }
|
|
4476
|
+
*
|
|
4477
|
+
* type Query {
|
|
4478
|
+
* resource: Resource
|
|
4479
|
+
* }
|
|
4480
|
+
* `);
|
|
4481
|
+
*
|
|
4482
|
+
* const Resource = assertInterfaceType(schema.getType('Resource'));
|
|
4483
|
+
* const implementations = schema.getImplementations(Resource);
|
|
4484
|
+
*
|
|
4485
|
+
* implementations.interfaces.map((type) => type.name); // => ['Image']
|
|
4486
|
+
* implementations.objects.map((type) => type.name); // => ['Photo']
|
|
4487
|
+
* ```
|
|
4488
|
+
*/
|
|
4489
|
+
getImplementations(interfaceType: GraphQLInterfaceType): {
|
|
4490
|
+
objects: ReadonlyArray<GraphQLObjectType>;
|
|
4491
|
+
interfaces: ReadonlyArray<GraphQLInterfaceType>;
|
|
4492
|
+
};
|
|
4493
|
+
/**
|
|
4494
|
+
* Returns whether one type is a possible runtime subtype of an abstract type.
|
|
4495
|
+
* @param abstractType - Interface or union type to inspect.
|
|
4496
|
+
* @param maybeSubType - Object or interface type to test as a possible subtype.
|
|
4497
|
+
* @returns True when the subtype may satisfy the abstract type.
|
|
4498
|
+
* @example
|
|
4499
|
+
* ```ts
|
|
4500
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4501
|
+
* import { assertInterfaceType, assertObjectType } from 'graphql/type';
|
|
4502
|
+
*
|
|
4503
|
+
* const schema = buildSchema(`
|
|
4504
|
+
* interface Node {
|
|
4505
|
+
* id: ID!
|
|
4506
|
+
* }
|
|
4507
|
+
*
|
|
4508
|
+
* type User implements Node {
|
|
4509
|
+
* id: ID!
|
|
4510
|
+
* }
|
|
4511
|
+
*
|
|
4512
|
+
* type Review {
|
|
4513
|
+
* body: String
|
|
4514
|
+
* }
|
|
4515
|
+
*
|
|
4516
|
+
* type Query {
|
|
4517
|
+
* node: Node
|
|
4518
|
+
* review: Review
|
|
4519
|
+
* }
|
|
4520
|
+
* `);
|
|
4521
|
+
*
|
|
4522
|
+
* const Node = assertInterfaceType(schema.getType('Node'));
|
|
4523
|
+
* const User = assertObjectType(schema.getType('User'));
|
|
4524
|
+
* const Review = assertObjectType(schema.getType('Review'));
|
|
4525
|
+
*
|
|
4526
|
+
* schema.isSubType(Node, User); // => true
|
|
4527
|
+
* schema.isSubType(Node, Review); // => false
|
|
4528
|
+
* ```
|
|
4529
|
+
*/
|
|
4530
|
+
isSubType(abstractType: GraphQLAbstractType, maybeSubType: GraphQLObjectType | GraphQLInterfaceType): boolean;
|
|
4531
|
+
/**
|
|
4532
|
+
* Returns directives available in this schema.
|
|
4533
|
+
* @returns Directives available in this schema.
|
|
4534
|
+
* @example
|
|
4535
|
+
* ```ts
|
|
4536
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4537
|
+
*
|
|
4538
|
+
* const schema = buildSchema(`
|
|
4539
|
+
* directive @upper on FIELD_DEFINITION
|
|
4540
|
+
*
|
|
4541
|
+
* type Query {
|
|
4542
|
+
* greeting: String @upper
|
|
4543
|
+
* }
|
|
4544
|
+
* `);
|
|
4545
|
+
*
|
|
4546
|
+
* schema.getDirectives().map((directive) => directive.name); // => ['include', 'skip', 'deprecated', 'specifiedBy', 'oneOf', 'upper']
|
|
4547
|
+
* ```
|
|
4548
|
+
*/
|
|
4549
|
+
getDirectives(): ReadonlyArray<GraphQLDirective>;
|
|
4550
|
+
/**
|
|
4551
|
+
* Returns the current directive definition.
|
|
4552
|
+
* @param name - The GraphQL name to look up.
|
|
4553
|
+
* @returns The current directive definition, if known.
|
|
4554
|
+
* @example
|
|
4555
|
+
* ```ts
|
|
4556
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4557
|
+
*
|
|
4558
|
+
* const schema = buildSchema(`
|
|
4559
|
+
* directive @upper on FIELD_DEFINITION
|
|
4560
|
+
*
|
|
4561
|
+
* type Query {
|
|
4562
|
+
* greeting: String @upper
|
|
4563
|
+
* }
|
|
4564
|
+
* `);
|
|
4565
|
+
*
|
|
4566
|
+
* schema.getDirective('upper')?.name; // => 'upper'
|
|
4567
|
+
* schema.getDirective('missing'); // => undefined
|
|
4568
|
+
* ```
|
|
4569
|
+
*/
|
|
4570
|
+
getDirective(name: string): Maybe<GraphQLDirective>;
|
|
4571
|
+
/**
|
|
4572
|
+
* This method looks up the field on the given type definition.
|
|
4573
|
+
* It has special casing for the three introspection fields, `__schema`,
|
|
4574
|
+
* `__type` and `__typename`.
|
|
4575
|
+
*
|
|
4576
|
+
* `__typename` is special because it can always be queried as a field, even
|
|
4577
|
+
* in situations where no other fields are allowed, like on a Union.
|
|
4578
|
+
*
|
|
4579
|
+
* `__schema` and `__type` could get automatically added to the query type,
|
|
4580
|
+
* but that would require mutating type definitions, which would cause issues.
|
|
4581
|
+
* @param parentType - Composite type to look up the field on.
|
|
4582
|
+
* @param fieldName - Field name to look up.
|
|
4583
|
+
* @returns The field definition, including supported introspection fields.
|
|
4584
|
+
* @example
|
|
4585
|
+
* ```ts
|
|
4586
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4587
|
+
*
|
|
4588
|
+
* const schema = buildSchema(`
|
|
4589
|
+
* type Query {
|
|
4590
|
+
* greeting: String
|
|
4591
|
+
* }
|
|
4592
|
+
* `);
|
|
4593
|
+
* const queryType = schema.getQueryType();
|
|
4594
|
+
*
|
|
4595
|
+
* schema.getField(queryType, 'greeting')?.name; // => 'greeting'
|
|
4596
|
+
* schema.getField(queryType, '__typename')?.name; // => '__typename'
|
|
4597
|
+
* schema.getField(queryType, 'missing'); // => undefined
|
|
4598
|
+
* ```
|
|
4599
|
+
*/
|
|
4600
|
+
getField(parentType: GraphQLCompositeType, fieldName: string): GraphQLField<unknown, unknown> | undefined;
|
|
4601
|
+
/**
|
|
4602
|
+
* Returns a normalized configuration object for this object.
|
|
4603
|
+
*
|
|
4604
|
+
* The returned config preserves the original `assumeValid` flag so the schema
|
|
4605
|
+
* can be recreated with the same validation behavior.
|
|
4606
|
+
* @returns A configuration object that can be used to recreate this object.
|
|
4607
|
+
* @example
|
|
4608
|
+
* ```ts
|
|
4609
|
+
* import { buildSchema } from 'graphql/utilities';
|
|
4610
|
+
* import { GraphQLSchema } from 'graphql/type';
|
|
4611
|
+
*
|
|
4612
|
+
* const schema = buildSchema(`
|
|
4613
|
+
* type Query {
|
|
4614
|
+
* greeting: String
|
|
4615
|
+
* }
|
|
4616
|
+
* `);
|
|
4617
|
+
*
|
|
4618
|
+
* const config = schema.toConfig();
|
|
4619
|
+
* const schemaCopy = new GraphQLSchema(config);
|
|
4620
|
+
*
|
|
4621
|
+
* config.query?.name; // => 'Query'
|
|
4622
|
+
* schemaCopy.getQueryType()?.name; // => 'Query'
|
|
4623
|
+
* ```
|
|
4624
|
+
*/
|
|
4625
|
+
toConfig(): GraphQLSchemaNormalizedConfig;
|
|
4626
|
+
}
|
|
4627
|
+
type TypeMap = ObjMap<GraphQLNamedType>;
|
|
4628
|
+
/** @internal */
|
|
4629
|
+
interface GraphQLSchemaValidationOptions {
|
|
4630
|
+
/**
|
|
4631
|
+
* When building a schema from a GraphQL service's introspection result, it
|
|
4632
|
+
* might be safe to assume the schema is valid. Set to true to assume the
|
|
4633
|
+
* produced schema is valid.
|
|
4634
|
+
*
|
|
4635
|
+
* Default: false
|
|
4636
|
+
*
|
|
4637
|
+
* @internal
|
|
4638
|
+
*/
|
|
4639
|
+
assumeValid?: boolean | undefined;
|
|
4640
|
+
}
|
|
4641
|
+
/** Configuration used to construct a GraphQLSchema. */
|
|
4642
|
+
interface GraphQLSchemaConfig extends GraphQLSchemaValidationOptions {
|
|
4643
|
+
/** Human-readable description for this schema element, if provided. */
|
|
4644
|
+
description?: Maybe<string>;
|
|
4645
|
+
/** Root object type for query operations. */
|
|
4646
|
+
query?: Maybe<GraphQLObjectType>;
|
|
4647
|
+
/** Root object type for mutation operations. */
|
|
4648
|
+
mutation?: Maybe<GraphQLObjectType>;
|
|
4649
|
+
/** Root object type for subscription operations. */
|
|
4650
|
+
subscription?: Maybe<GraphQLObjectType>;
|
|
4651
|
+
/** Object types that belong to this union type. */
|
|
4652
|
+
types?: Maybe<ReadonlyArray<GraphQLNamedType>>;
|
|
4653
|
+
/** Directives available in this schema or applied to this AST node. */
|
|
4654
|
+
directives?: Maybe<ReadonlyArray<GraphQLDirective>>;
|
|
4655
|
+
/** Custom extension fields reserved for users. */
|
|
4656
|
+
extensions?: Maybe<Readonly<GraphQLSchemaExtensions>>;
|
|
4657
|
+
/** AST node from which this schema element was built, if available. */
|
|
4658
|
+
astNode?: Maybe<SchemaDefinitionNode>;
|
|
4659
|
+
/** AST extension nodes applied to this schema element. */
|
|
4660
|
+
extensionASTNodes?: Maybe<ReadonlyArray<SchemaExtensionNode>>;
|
|
4661
|
+
}
|
|
4662
|
+
/** @internal */
|
|
4663
|
+
interface GraphQLSchemaNormalizedConfig extends GraphQLSchemaConfig {
|
|
4664
|
+
description: Maybe<string>;
|
|
4665
|
+
types: ReadonlyArray<GraphQLNamedType>;
|
|
4666
|
+
directives: ReadonlyArray<GraphQLDirective>;
|
|
4667
|
+
extensions: Readonly<GraphQLSchemaExtensions>;
|
|
4668
|
+
extensionASTNodes: ReadonlyArray<SchemaExtensionNode>;
|
|
4669
|
+
assumeValid: boolean;
|
|
4670
|
+
}
|
|
4671
|
+
//#endregion
|
|
4672
|
+
//#region src/index.d.ts
|
|
4673
|
+
type Options = Types.GenerateOptions;
|
|
4674
|
+
declare const _default: import("@power-plant/core").GeneratorConfigObject<GraphQLSchema, Types.GenerateOptions, void>;
|
|
4675
|
+
//#endregion
|
|
4676
|
+
export { Options, _default as default };
|
|
4677
|
+
//# sourceMappingURL=index.d.mts.map
|