UNPKG

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