UNPKG

31.4 kBTypeScriptView Raw
1import type { Maybe } from '../jsutils/Maybe';
2import type { ObjMap } from '../jsutils/ObjMap';
3import type { Path } from '../jsutils/Path';
4import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
5import type {
6 EnumTypeDefinitionNode,
7 EnumTypeExtensionNode,
8 EnumValueDefinitionNode,
9 FieldDefinitionNode,
10 FieldNode,
11 FragmentDefinitionNode,
12 InputObjectTypeDefinitionNode,
13 InputObjectTypeExtensionNode,
14 InputValueDefinitionNode,
15 InterfaceTypeDefinitionNode,
16 InterfaceTypeExtensionNode,
17 ObjectTypeDefinitionNode,
18 ObjectTypeExtensionNode,
19 OperationDefinitionNode,
20 ScalarTypeDefinitionNode,
21 ScalarTypeExtensionNode,
22 UnionTypeDefinitionNode,
23 UnionTypeExtensionNode,
24 ValueNode,
25} from '../language/ast';
26import type { GraphQLSchema } from './schema';
27/**
28 * These are all of the possible kinds of types.
29 */
30export declare type GraphQLType =
31 | GraphQLScalarType
32 | GraphQLObjectType
33 | GraphQLInterfaceType
34 | GraphQLUnionType
35 | GraphQLEnumType
36 | GraphQLInputObjectType
37 | GraphQLList<GraphQLType>
38 | GraphQLNonNull<
39 | GraphQLScalarType
40 | GraphQLObjectType
41 | GraphQLInterfaceType
42 | GraphQLUnionType
43 | GraphQLEnumType
44 | GraphQLInputObjectType
45 | GraphQLList<GraphQLType>
46 >;
47export declare function isType(type: unknown): type is GraphQLType;
48export declare function assertType(type: unknown): GraphQLType;
49/**
50 * There are predicates for each kind of GraphQL type.
51 */
52export declare function isScalarType(type: unknown): type is GraphQLScalarType;
53export declare function assertScalarType(type: unknown): GraphQLScalarType;
54export declare function isObjectType(type: unknown): type is GraphQLObjectType;
55export declare function assertObjectType(type: unknown): GraphQLObjectType;
56export declare function isInterfaceType(
57 type: unknown,
58): type is GraphQLInterfaceType;
59export declare function assertInterfaceType(
60 type: unknown,
61): GraphQLInterfaceType;
62export declare function isUnionType(type: unknown): type is GraphQLUnionType;
63export declare function assertUnionType(type: unknown): GraphQLUnionType;
64export declare function isEnumType(type: unknown): type is GraphQLEnumType;
65export declare function assertEnumType(type: unknown): GraphQLEnumType;
66export declare function isInputObjectType(
67 type: unknown,
68): type is GraphQLInputObjectType;
69export declare function assertInputObjectType(
70 type: unknown,
71): GraphQLInputObjectType;
72export declare function isListType(
73 type: GraphQLInputType,
74): type is GraphQLList<GraphQLInputType>;
75export declare function isListType(
76 type: GraphQLOutputType,
77): type is GraphQLList<GraphQLOutputType>;
78export declare function isListType(
79 type: unknown,
80): type is GraphQLList<GraphQLType>;
81export declare function assertListType(type: unknown): GraphQLList<GraphQLType>;
82export declare function isNonNullType(
83 type: GraphQLInputType,
84): type is GraphQLNonNull<GraphQLInputType>;
85export declare function isNonNullType(
86 type: GraphQLOutputType,
87): type is GraphQLNonNull<GraphQLOutputType>;
88export declare function isNonNullType(
89 type: unknown,
90): type is GraphQLNonNull<GraphQLType>;
91export declare function assertNonNullType(
92 type: unknown,
93): GraphQLNonNull<GraphQLType>;
94/**
95 * These types may be used as input types for arguments and directives.
96 */
97export declare type GraphQLInputType =
98 | GraphQLScalarType
99 | GraphQLEnumType
100 | GraphQLInputObjectType
101 | GraphQLList<GraphQLInputType>
102 | GraphQLNonNull<
103 | GraphQLScalarType
104 | GraphQLEnumType
105 | GraphQLInputObjectType
106 | GraphQLList<GraphQLInputType>
107 >;
108export declare function isInputType(type: unknown): type is GraphQLInputType;
109export declare function assertInputType(type: unknown): GraphQLInputType;
110/**
111 * These types may be used as output types as the result of fields.
112 */
113export declare type GraphQLOutputType =
114 | GraphQLScalarType
115 | GraphQLObjectType
116 | GraphQLInterfaceType
117 | GraphQLUnionType
118 | GraphQLEnumType
119 | GraphQLList<GraphQLOutputType>
120 | GraphQLNonNull<
121 | GraphQLScalarType
122 | GraphQLObjectType
123 | GraphQLInterfaceType
124 | GraphQLUnionType
125 | GraphQLEnumType
126 | GraphQLList<GraphQLOutputType>
127 >;
128export declare function isOutputType(type: unknown): type is GraphQLOutputType;
129export declare function assertOutputType(type: unknown): GraphQLOutputType;
130/**
131 * These types may describe types which may be leaf values.
132 */
133export declare type GraphQLLeafType = GraphQLScalarType | GraphQLEnumType;
134export declare function isLeafType(type: unknown): type is GraphQLLeafType;
135export declare function assertLeafType(type: unknown): GraphQLLeafType;
136/**
137 * These types may describe the parent context of a selection set.
138 */
139export declare type GraphQLCompositeType =
140 | GraphQLObjectType
141 | GraphQLInterfaceType
142 | GraphQLUnionType;
143export declare function isCompositeType(
144 type: unknown,
145): type is GraphQLCompositeType;
146export declare function assertCompositeType(
147 type: unknown,
148): GraphQLCompositeType;
149/**
150 * These types may describe the parent context of a selection set.
151 */
152export declare type GraphQLAbstractType =
153 | GraphQLInterfaceType
154 | GraphQLUnionType;
155export declare function isAbstractType(
156 type: unknown,
157): type is GraphQLAbstractType;
158export declare function assertAbstractType(type: unknown): GraphQLAbstractType;
159/**
160 * List Type Wrapper
161 *
162 * A list is a wrapping type which points to another type.
163 * Lists are often created within the context of defining the fields of
164 * an object type.
165 *
166 * Example:
167 *
168 * ```ts
169 * const PersonType = new GraphQLObjectType({
170 * name: 'Person',
171 * fields: () => ({
172 * parents: { type: new GraphQLList(PersonType) },
173 * children: { type: new GraphQLList(PersonType) },
174 * })
175 * })
176 * ```
177 */
178export declare class GraphQLList<T extends GraphQLType> {
179 readonly ofType: T;
180 constructor(ofType: T);
181 get [Symbol.toStringTag](): string;
182 toString(): string;
183 toJSON(): string;
184}
185/**
186 * Non-Null Type Wrapper
187 *
188 * A non-null is a wrapping type which points to another type.
189 * Non-null types enforce that their values are never null and can ensure
190 * an error is raised if this ever occurs during a request. It is useful for
191 * fields which you can make a strong guarantee on non-nullability, for example
192 * usually the id field of a database row will never be null.
193 *
194 * Example:
195 *
196 * ```ts
197 * const RowType = new GraphQLObjectType({
198 * name: 'Row',
199 * fields: () => ({
200 * id: { type: new GraphQLNonNull(GraphQLString) },
201 * })
202 * })
203 * ```
204 * Note: the enforcement of non-nullability occurs within the executor.
205 */
206export declare class GraphQLNonNull<T extends GraphQLNullableType> {
207 readonly ofType: T;
208 constructor(ofType: T);
209 get [Symbol.toStringTag](): string;
210 toString(): string;
211 toJSON(): string;
212}
213/**
214 * These types wrap and modify other types
215 */
216export declare type GraphQLWrappingType =
217 | GraphQLList<GraphQLType>
218 | GraphQLNonNull<GraphQLType>;
219export declare function isWrappingType(
220 type: unknown,
221): type is GraphQLWrappingType;
222export declare function assertWrappingType(type: unknown): GraphQLWrappingType;
223/**
224 * These types can all accept null as a value.
225 */
226export declare type GraphQLNullableType =
227 | GraphQLScalarType
228 | GraphQLObjectType
229 | GraphQLInterfaceType
230 | GraphQLUnionType
231 | GraphQLEnumType
232 | GraphQLInputObjectType
233 | GraphQLList<GraphQLType>;
234export declare function isNullableType(
235 type: unknown,
236): type is GraphQLNullableType;
237export declare function assertNullableType(type: unknown): GraphQLNullableType;
238export declare function getNullableType(type: undefined | null): void;
239export declare function getNullableType<T extends GraphQLNullableType>(
240 type: T | GraphQLNonNull<T>,
241): T;
242export declare function getNullableType(
243 type: Maybe<GraphQLType>,
244): GraphQLNullableType | undefined;
245/**
246 * These named types do not include modifiers like List or NonNull.
247 */
248export declare type GraphQLNamedType =
249 | GraphQLNamedInputType
250 | GraphQLNamedOutputType;
251export declare type GraphQLNamedInputType =
252 | GraphQLScalarType
253 | GraphQLEnumType
254 | GraphQLInputObjectType;
255export declare type GraphQLNamedOutputType =
256 | GraphQLScalarType
257 | GraphQLObjectType
258 | GraphQLInterfaceType
259 | GraphQLUnionType
260 | GraphQLEnumType;
261export declare function isNamedType(type: unknown): type is GraphQLNamedType;
262export declare function assertNamedType(type: unknown): GraphQLNamedType;
263export declare function getNamedType(type: undefined | null): void;
264export declare function getNamedType(
265 type: GraphQLInputType,
266): GraphQLNamedInputType;
267export declare function getNamedType(
268 type: GraphQLOutputType,
269): GraphQLNamedOutputType;
270export declare function getNamedType(type: GraphQLType): GraphQLNamedType;
271export declare function getNamedType(
272 type: Maybe<GraphQLType>,
273): GraphQLNamedType | undefined;
274/**
275 * Used while defining GraphQL types to allow for circular references in
276 * otherwise immutable type definitions.
277 */
278export declare type ThunkReadonlyArray<T> =
279 | (() => ReadonlyArray<T>)
280 | ReadonlyArray<T>;
281export declare type ThunkObjMap<T> = (() => ObjMap<T>) | ObjMap<T>;
282export declare function resolveReadonlyArrayThunk<T>(
283 thunk: ThunkReadonlyArray<T>,
284): ReadonlyArray<T>;
285export declare function resolveObjMapThunk<T>(thunk: ThunkObjMap<T>): ObjMap<T>;
286/**
287 * Custom extensions
288 *
289 * @remarks
290 * Use a unique identifier name for your extension, for example the name of
291 * your library or project. Do not use a shortened identifier as this increases
292 * the risk of conflicts. We recommend you add at most one extension field,
293 * an object which can contain all the values you need.
294 */
295export interface GraphQLScalarTypeExtensions {
296 [attributeName: string]: unknown;
297}
298/**
299 * Scalar Type Definition
300 *
301 * The leaf values of any request and input values to arguments are
302 * Scalars (or Enums) and are defined with a name and a series of functions
303 * used to parse input from ast or variables and to ensure validity.
304 *
305 * If a type's serialize function returns `null` or does not return a value
306 * (i.e. it returns `undefined`) then an error will be raised and a `null`
307 * value will be returned in the response. It is always better to validate
308 *
309 * Example:
310 *
311 * ```ts
312 * const OddType = new GraphQLScalarType({
313 * name: 'Odd',
314 * serialize(value) {
315 * if (!Number.isFinite(value)) {
316 * throw new Error(
317 * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`,
318 * );
319 * }
320 *
321 * if (value % 2 === 0) {
322 * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`);
323 * }
324 * return value;
325 * }
326 * });
327 * ```
328 */
329export declare class GraphQLScalarType<
330 TInternal = unknown,
331 TExternal = TInternal,
332> {
333 name: string;
334 description: Maybe<string>;
335 specifiedByURL: Maybe<string>;
336 serialize: GraphQLScalarSerializer<TExternal>;
337 parseValue: GraphQLScalarValueParser<TInternal>;
338 parseLiteral: GraphQLScalarLiteralParser<TInternal>;
339 extensions: Readonly<GraphQLScalarTypeExtensions>;
340 astNode: Maybe<ScalarTypeDefinitionNode>;
341 extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
342 constructor(config: Readonly<GraphQLScalarTypeConfig<TInternal, TExternal>>);
343 get [Symbol.toStringTag](): string;
344 toConfig(): GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>;
345 toString(): string;
346 toJSON(): string;
347}
348export declare type GraphQLScalarSerializer<TExternal> = (
349 outputValue: unknown,
350) => TExternal;
351export declare type GraphQLScalarValueParser<TInternal> = (
352 inputValue: unknown,
353) => TInternal;
354export declare type GraphQLScalarLiteralParser<TInternal> = (
355 valueNode: ValueNode,
356 variables?: Maybe<ObjMap<unknown>>,
357) => TInternal;
358export interface GraphQLScalarTypeConfig<TInternal, TExternal> {
359 name: string;
360 description?: Maybe<string>;
361 specifiedByURL?: Maybe<string>;
362 /** Serializes an internal value to include in a response. */
363 serialize?: GraphQLScalarSerializer<TExternal>;
364 /** Parses an externally provided value to use as an input. */
365 parseValue?: GraphQLScalarValueParser<TInternal>;
366 /** Parses an externally provided literal value to use as an input. */
367 parseLiteral?: GraphQLScalarLiteralParser<TInternal>;
368 extensions?: Maybe<Readonly<GraphQLScalarTypeExtensions>>;
369 astNode?: Maybe<ScalarTypeDefinitionNode>;
370 extensionASTNodes?: Maybe<ReadonlyArray<ScalarTypeExtensionNode>>;
371}
372interface GraphQLScalarTypeNormalizedConfig<TInternal, TExternal>
373 extends GraphQLScalarTypeConfig<TInternal, TExternal> {
374 serialize: GraphQLScalarSerializer<TExternal>;
375 parseValue: GraphQLScalarValueParser<TInternal>;
376 parseLiteral: GraphQLScalarLiteralParser<TInternal>;
377 extensions: Readonly<GraphQLScalarTypeExtensions>;
378 extensionASTNodes: ReadonlyArray<ScalarTypeExtensionNode>;
379}
380/**
381 * Custom extensions
382 *
383 * @remarks
384 * Use a unique identifier name for your extension, for example the name of
385 * your library or project. Do not use a shortened identifier as this increases
386 * the risk of conflicts. We recommend you add at most one extension field,
387 * an object which can contain all the values you need.
388 *
389 * We've provided these template arguments because this is an open type and
390 * you may find them useful.
391 */
392export interface GraphQLObjectTypeExtensions<_TSource = any, _TContext = any> {
393 [attributeName: string]: unknown;
394}
395/**
396 * Object Type Definition
397 *
398 * Almost all of the GraphQL types you define will be object types. Object types
399 * have a name, but most importantly describe their fields.
400 *
401 * Example:
402 *
403 * ```ts
404 * const AddressType = new GraphQLObjectType({
405 * name: 'Address',
406 * fields: {
407 * street: { type: GraphQLString },
408 * number: { type: GraphQLInt },
409 * formatted: {
410 * type: GraphQLString,
411 * resolve(obj) {
412 * return obj.number + ' ' + obj.street
413 * }
414 * }
415 * }
416 * });
417 * ```
418 *
419 * When two types need to refer to each other, or a type needs to refer to
420 * itself in a field, you can use a function expression (aka a closure or a
421 * thunk) to supply the fields lazily.
422 *
423 * Example:
424 *
425 * ```ts
426 * const PersonType = new GraphQLObjectType({
427 * name: 'Person',
428 * fields: () => ({
429 * name: { type: GraphQLString },
430 * bestFriend: { type: PersonType },
431 * })
432 * });
433 * ```
434 */
435export declare class GraphQLObjectType<TSource = any, TContext = any> {
436 name: string;
437 description: Maybe<string>;
438 isTypeOf: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
439 extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
440 astNode: Maybe<ObjectTypeDefinitionNode>;
441 extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
442 private _fields;
443 private _interfaces;
444 constructor(config: Readonly<GraphQLObjectTypeConfig<TSource, TContext>>);
445 get [Symbol.toStringTag](): string;
446 getFields(): GraphQLFieldMap<TSource, TContext>;
447 getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
448 toConfig(): GraphQLObjectTypeNormalizedConfig<TSource, TContext>;
449 toString(): string;
450 toJSON(): string;
451}
452export declare function defineArguments(
453 config: GraphQLFieldConfigArgumentMap,
454): ReadonlyArray<GraphQLArgument>;
455/**
456 * @internal
457 */
458export declare function argsToArgsConfig(
459 args: ReadonlyArray<GraphQLArgument>,
460): GraphQLFieldConfigArgumentMap;
461export interface GraphQLObjectTypeConfig<TSource, TContext> {
462 name: string;
463 description?: Maybe<string>;
464 interfaces?: ThunkReadonlyArray<GraphQLInterfaceType>;
465 fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
466 isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
467 extensions?: Maybe<Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>>;
468 astNode?: Maybe<ObjectTypeDefinitionNode>;
469 extensionASTNodes?: Maybe<ReadonlyArray<ObjectTypeExtensionNode>>;
470}
471interface GraphQLObjectTypeNormalizedConfig<TSource, TContext>
472 extends GraphQLObjectTypeConfig<any, any> {
473 interfaces: ReadonlyArray<GraphQLInterfaceType>;
474 fields: GraphQLFieldConfigMap<any, any>;
475 extensions: Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>;
476 extensionASTNodes: ReadonlyArray<ObjectTypeExtensionNode>;
477}
478export declare type GraphQLTypeResolver<TSource, TContext> = (
479 value: TSource,
480 context: TContext,
481 info: GraphQLResolveInfo,
482 abstractType: GraphQLAbstractType,
483) => PromiseOrValue<string | undefined>;
484export declare type GraphQLIsTypeOfFn<TSource, TContext> = (
485 source: TSource,
486 context: TContext,
487 info: GraphQLResolveInfo,
488) => PromiseOrValue<boolean>;
489export declare type GraphQLFieldResolver<
490 TSource,
491 TContext,
492 TArgs = any,
493 TResult = unknown,
494> = (
495 source: TSource,
496 args: TArgs,
497 context: TContext,
498 info: GraphQLResolveInfo,
499) => TResult;
500export interface GraphQLResolveInfo {
501 readonly fieldName: string;
502 readonly fieldNodes: ReadonlyArray<FieldNode>;
503 readonly returnType: GraphQLOutputType;
504 readonly parentType: GraphQLObjectType;
505 readonly path: Path;
506 readonly schema: GraphQLSchema;
507 readonly fragments: ObjMap<FragmentDefinitionNode>;
508 readonly rootValue: unknown;
509 readonly operation: OperationDefinitionNode;
510 readonly variableValues: {
511 [variable: string]: unknown;
512 };
513}
514/**
515 * Custom extensions
516 *
517 * @remarks
518 * Use a unique identifier name for your extension, for example the name of
519 * your library or project. Do not use a shortened identifier as this increases
520 * the risk of conflicts. We recommend you add at most one extension field,
521 * an object which can contain all the values you need.
522 *
523 * We've provided these template arguments because this is an open type and
524 * you may find them useful.
525 */
526export interface GraphQLFieldExtensions<_TSource, _TContext, _TArgs = any> {
527 [attributeName: string]: unknown;
528}
529export interface GraphQLFieldConfig<TSource, TContext, TArgs = any> {
530 description?: Maybe<string>;
531 type: GraphQLOutputType;
532 args?: GraphQLFieldConfigArgumentMap;
533 resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
534 subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
535 deprecationReason?: Maybe<string>;
536 extensions?: Maybe<
537 Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>
538 >;
539 astNode?: Maybe<FieldDefinitionNode>;
540}
541export declare type GraphQLFieldConfigArgumentMap =
542 ObjMap<GraphQLArgumentConfig>;
543/**
544 * Custom extensions
545 *
546 * @remarks
547 * Use a unique identifier name for your extension, for example the name of
548 * your library or project. Do not use a shortened identifier as this increases
549 * the risk of conflicts. We recommend you add at most one extension field,
550 * an object which can contain all the values you need.
551 */
552export interface GraphQLArgumentExtensions {
553 [attributeName: string]: unknown;
554}
555export interface GraphQLArgumentConfig {
556 description?: Maybe<string>;
557 type: GraphQLInputType;
558 defaultValue?: unknown;
559 deprecationReason?: Maybe<string>;
560 extensions?: Maybe<Readonly<GraphQLArgumentExtensions>>;
561 astNode?: Maybe<InputValueDefinitionNode>;
562}
563export declare type GraphQLFieldConfigMap<TSource, TContext> = ObjMap<
564 GraphQLFieldConfig<TSource, TContext>
565>;
566export interface GraphQLField<TSource, TContext, TArgs = any> {
567 name: string;
568 description: Maybe<string>;
569 type: GraphQLOutputType;
570 args: ReadonlyArray<GraphQLArgument>;
571 resolve?: GraphQLFieldResolver<TSource, TContext, TArgs>;
572 subscribe?: GraphQLFieldResolver<TSource, TContext, TArgs>;
573 deprecationReason: Maybe<string>;
574 extensions: Readonly<GraphQLFieldExtensions<TSource, TContext, TArgs>>;
575 astNode: Maybe<FieldDefinitionNode>;
576}
577export interface GraphQLArgument {
578 name: string;
579 description: Maybe<string>;
580 type: GraphQLInputType;
581 defaultValue: unknown;
582 deprecationReason: Maybe<string>;
583 extensions: Readonly<GraphQLArgumentExtensions>;
584 astNode: Maybe<InputValueDefinitionNode>;
585}
586export declare function isRequiredArgument(arg: GraphQLArgument): boolean;
587export declare type GraphQLFieldMap<TSource, TContext> = ObjMap<
588 GraphQLField<TSource, TContext>
589>;
590/**
591 * Custom extensions
592 *
593 * @remarks
594 * Use a unique identifier name for your extension, for example the name of
595 * your library or project. Do not use a shortened identifier as this increases
596 * the risk of conflicts. We recommend you add at most one extension field,
597 * an object which can contain all the values you need.
598 */
599export interface GraphQLInterfaceTypeExtensions {
600 [attributeName: string]: unknown;
601}
602/**
603 * Interface Type Definition
604 *
605 * When a field can return one of a heterogeneous set of types, a Interface type
606 * is used to describe what types are possible, what fields are in common across
607 * all types, as well as a function to determine which type is actually used
608 * when the field is resolved.
609 *
610 * Example:
611 *
612 * ```ts
613 * const EntityType = new GraphQLInterfaceType({
614 * name: 'Entity',
615 * fields: {
616 * name: { type: GraphQLString }
617 * }
618 * });
619 * ```
620 */
621export declare class GraphQLInterfaceType {
622 name: string;
623 description: Maybe<string>;
624 resolveType: Maybe<GraphQLTypeResolver<any, any>>;
625 extensions: Readonly<GraphQLInterfaceTypeExtensions>;
626 astNode: Maybe<InterfaceTypeDefinitionNode>;
627 extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
628 private _fields;
629 private _interfaces;
630 constructor(config: Readonly<GraphQLInterfaceTypeConfig<any, any>>);
631 get [Symbol.toStringTag](): string;
632 getFields(): GraphQLFieldMap<any, any>;
633 getInterfaces(): ReadonlyArray<GraphQLInterfaceType>;
634 toConfig(): GraphQLInterfaceTypeNormalizedConfig;
635 toString(): string;
636 toJSON(): string;
637}
638export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
639 name: string;
640 description?: Maybe<string>;
641 interfaces?: ThunkReadonlyArray<GraphQLInterfaceType>;
642 fields: ThunkObjMap<GraphQLFieldConfig<TSource, TContext>>;
643 /**
644 * Optionally provide a custom type resolver function. If one is not provided,
645 * the default implementation will call `isTypeOf` on each implementing
646 * Object type.
647 */
648 resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
649 extensions?: Maybe<Readonly<GraphQLInterfaceTypeExtensions>>;
650 astNode?: Maybe<InterfaceTypeDefinitionNode>;
651 extensionASTNodes?: Maybe<ReadonlyArray<InterfaceTypeExtensionNode>>;
652}
653export interface GraphQLInterfaceTypeNormalizedConfig
654 extends GraphQLInterfaceTypeConfig<any, any> {
655 interfaces: ReadonlyArray<GraphQLInterfaceType>;
656 fields: GraphQLFieldConfigMap<any, any>;
657 extensions: Readonly<GraphQLInterfaceTypeExtensions>;
658 extensionASTNodes: ReadonlyArray<InterfaceTypeExtensionNode>;
659}
660/**
661 * Custom extensions
662 *
663 * @remarks
664 * Use a unique identifier name for your extension, for example the name of
665 * your library or project. Do not use a shortened identifier as this increases
666 * the risk of conflicts. We recommend you add at most one extension field,
667 * an object which can contain all the values you need.
668 */
669export interface GraphQLUnionTypeExtensions {
670 [attributeName: string]: unknown;
671}
672/**
673 * Union Type Definition
674 *
675 * When a field can return one of a heterogeneous set of types, a Union type
676 * is used to describe what types are possible as well as providing a function
677 * to determine which type is actually used when the field is resolved.
678 *
679 * Example:
680 *
681 * ```ts
682 * const PetType = new GraphQLUnionType({
683 * name: 'Pet',
684 * types: [ DogType, CatType ],
685 * resolveType(value) {
686 * if (value instanceof Dog) {
687 * return DogType;
688 * }
689 * if (value instanceof Cat) {
690 * return CatType;
691 * }
692 * }
693 * });
694 * ```
695 */
696export declare class GraphQLUnionType {
697 name: string;
698 description: Maybe<string>;
699 resolveType: Maybe<GraphQLTypeResolver<any, any>>;
700 extensions: Readonly<GraphQLUnionTypeExtensions>;
701 astNode: Maybe<UnionTypeDefinitionNode>;
702 extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
703 private _types;
704 constructor(config: Readonly<GraphQLUnionTypeConfig<any, any>>);
705 get [Symbol.toStringTag](): string;
706 getTypes(): ReadonlyArray<GraphQLObjectType>;
707 toConfig(): GraphQLUnionTypeNormalizedConfig;
708 toString(): string;
709 toJSON(): string;
710}
711export interface GraphQLUnionTypeConfig<TSource, TContext> {
712 name: string;
713 description?: Maybe<string>;
714 types: ThunkReadonlyArray<GraphQLObjectType>;
715 /**
716 * Optionally provide a custom type resolver function. If one is not provided,
717 * the default implementation will call `isTypeOf` on each implementing
718 * Object type.
719 */
720 resolveType?: Maybe<GraphQLTypeResolver<TSource, TContext>>;
721 extensions?: Maybe<Readonly<GraphQLUnionTypeExtensions>>;
722 astNode?: Maybe<UnionTypeDefinitionNode>;
723 extensionASTNodes?: Maybe<ReadonlyArray<UnionTypeExtensionNode>>;
724}
725interface GraphQLUnionTypeNormalizedConfig
726 extends GraphQLUnionTypeConfig<any, any> {
727 types: ReadonlyArray<GraphQLObjectType>;
728 extensions: Readonly<GraphQLUnionTypeExtensions>;
729 extensionASTNodes: ReadonlyArray<UnionTypeExtensionNode>;
730}
731/**
732 * Custom extensions
733 *
734 * @remarks
735 * Use a unique identifier name for your extension, for example the name of
736 * your library or project. Do not use a shortened identifier as this increases
737 * the risk of conflicts. We recommend you add at most one extension field,
738 * an object which can contain all the values you need.
739 */
740export interface GraphQLEnumTypeExtensions {
741 [attributeName: string]: unknown;
742}
743/**
744 * Enum Type Definition
745 *
746 * Some leaf values of requests and input values are Enums. GraphQL serializes
747 * Enum values as strings, however internally Enums can be represented by any
748 * kind of type, often integers.
749 *
750 * Example:
751 *
752 * ```ts
753 * const RGBType = new GraphQLEnumType({
754 * name: 'RGB',
755 * values: {
756 * RED: { value: 0 },
757 * GREEN: { value: 1 },
758 * BLUE: { value: 2 }
759 * }
760 * });
761 * ```
762 *
763 * Note: If a value is not provided in a definition, the name of the enum value
764 * will be used as its internal value.
765 */
766export declare class GraphQLEnumType {
767 name: string;
768 description: Maybe<string>;
769 extensions: Readonly<GraphQLEnumTypeExtensions>;
770 astNode: Maybe<EnumTypeDefinitionNode>;
771 extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
772 private _values;
773 private _valueLookup;
774 private _nameLookup;
775 constructor(config: Readonly<GraphQLEnumTypeConfig>);
776 get [Symbol.toStringTag](): string;
777 getValues(): ReadonlyArray<GraphQLEnumValue>;
778 getValue(name: string): Maybe<GraphQLEnumValue>;
779 serialize(outputValue: unknown): Maybe<string>;
780 parseValue(inputValue: unknown): Maybe<any>;
781 parseLiteral(
782 valueNode: ValueNode,
783 _variables: Maybe<ObjMap<unknown>>,
784 ): Maybe<any>;
785 toConfig(): GraphQLEnumTypeNormalizedConfig;
786 toString(): string;
787 toJSON(): string;
788}
789export interface GraphQLEnumTypeConfig {
790 name: string;
791 description?: Maybe<string>;
792 values: ThunkObjMap<GraphQLEnumValueConfig>;
793 extensions?: Maybe<Readonly<GraphQLEnumTypeExtensions>>;
794 astNode?: Maybe<EnumTypeDefinitionNode>;
795 extensionASTNodes?: Maybe<ReadonlyArray<EnumTypeExtensionNode>>;
796}
797interface GraphQLEnumTypeNormalizedConfig extends GraphQLEnumTypeConfig {
798 values: ObjMap<GraphQLEnumValueConfig>;
799 extensions: Readonly<GraphQLEnumTypeExtensions>;
800 extensionASTNodes: ReadonlyArray<EnumTypeExtensionNode>;
801}
802export declare type GraphQLEnumValueConfigMap = ObjMap<GraphQLEnumValueConfig>;
803/**
804 * Custom extensions
805 *
806 * @remarks
807 * Use a unique identifier name for your extension, for example the name of
808 * your library or project. Do not use a shortened identifier as this increases
809 * the risk of conflicts. We recommend you add at most one extension field,
810 * an object which can contain all the values you need.
811 */
812export interface GraphQLEnumValueExtensions {
813 [attributeName: string]: unknown;
814}
815export interface GraphQLEnumValueConfig {
816 description?: Maybe<string>;
817 value?: any;
818 deprecationReason?: Maybe<string>;
819 extensions?: Maybe<Readonly<GraphQLEnumValueExtensions>>;
820 astNode?: Maybe<EnumValueDefinitionNode>;
821}
822export interface GraphQLEnumValue {
823 name: string;
824 description: Maybe<string>;
825 value: any;
826 deprecationReason: Maybe<string>;
827 extensions: Readonly<GraphQLEnumValueExtensions>;
828 astNode: Maybe<EnumValueDefinitionNode>;
829}
830/**
831 * Custom extensions
832 *
833 * @remarks
834 * Use a unique identifier name for your extension, for example the name of
835 * your library or project. Do not use a shortened identifier as this increases
836 * the risk of conflicts. We recommend you add at most one extension field,
837 * an object which can contain all the values you need.
838 */
839export interface GraphQLInputObjectTypeExtensions {
840 [attributeName: string]: unknown;
841}
842/**
843 * Input Object Type Definition
844 *
845 * An input object defines a structured collection of fields which may be
846 * supplied to a field argument.
847 *
848 * Using `NonNull` will ensure that a value must be provided by the query
849 *
850 * Example:
851 *
852 * ```ts
853 * const GeoPoint = new GraphQLInputObjectType({
854 * name: 'GeoPoint',
855 * fields: {
856 * lat: { type: new GraphQLNonNull(GraphQLFloat) },
857 * lon: { type: new GraphQLNonNull(GraphQLFloat) },
858 * alt: { type: GraphQLFloat, defaultValue: 0 },
859 * }
860 * });
861 * ```
862 */
863export declare class GraphQLInputObjectType {
864 name: string;
865 description: Maybe<string>;
866 extensions: Readonly<GraphQLInputObjectTypeExtensions>;
867 astNode: Maybe<InputObjectTypeDefinitionNode>;
868 extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
869 isOneOf: boolean;
870 private _fields;
871 constructor(config: Readonly<GraphQLInputObjectTypeConfig>);
872 get [Symbol.toStringTag](): string;
873 getFields(): GraphQLInputFieldMap;
874 toConfig(): GraphQLInputObjectTypeNormalizedConfig;
875 toString(): string;
876 toJSON(): string;
877}
878export interface GraphQLInputObjectTypeConfig {
879 name: string;
880 description?: Maybe<string>;
881 fields: ThunkObjMap<GraphQLInputFieldConfig>;
882 extensions?: Maybe<Readonly<GraphQLInputObjectTypeExtensions>>;
883 astNode?: Maybe<InputObjectTypeDefinitionNode>;
884 extensionASTNodes?: Maybe<ReadonlyArray<InputObjectTypeExtensionNode>>;
885 isOneOf?: boolean;
886}
887interface GraphQLInputObjectTypeNormalizedConfig
888 extends GraphQLInputObjectTypeConfig {
889 fields: GraphQLInputFieldConfigMap;
890 extensions: Readonly<GraphQLInputObjectTypeExtensions>;
891 extensionASTNodes: ReadonlyArray<InputObjectTypeExtensionNode>;
892}
893/**
894 * Custom extensions
895 *
896 * @remarks
897 * Use a unique identifier name for your extension, for example the name of
898 * your library or project. Do not use a shortened identifier as this increases
899 * the risk of conflicts. We recommend you add at most one extension field,
900 * an object which can contain all the values you need.
901 */
902export interface GraphQLInputFieldExtensions {
903 [attributeName: string]: unknown;
904}
905export interface GraphQLInputFieldConfig {
906 description?: Maybe<string>;
907 type: GraphQLInputType;
908 defaultValue?: unknown;
909 deprecationReason?: Maybe<string>;
910 extensions?: Maybe<Readonly<GraphQLInputFieldExtensions>>;
911 astNode?: Maybe<InputValueDefinitionNode>;
912}
913export declare type GraphQLInputFieldConfigMap =
914 ObjMap<GraphQLInputFieldConfig>;
915export interface GraphQLInputField {
916 name: string;
917 description: Maybe<string>;
918 type: GraphQLInputType;
919 defaultValue: unknown;
920 deprecationReason: Maybe<string>;
921 extensions: Readonly<GraphQLInputFieldExtensions>;
922 astNode: Maybe<InputValueDefinitionNode>;
923}
924export declare function isRequiredInputField(field: GraphQLInputField): boolean;
925export declare type GraphQLInputFieldMap = ObjMap<GraphQLInputField>;
926export {};