UNPKG

7.5 kBTypeScriptView Raw
1import { GraphQLInputObjectType } from './graphql';
2import { TypeInPath } from './utils/typeByPath';
3import type { ThunkWithSchemaComposer, ObjMap, Extensions, Directive, DirectiveArgs } from './utils/definitions';
4import { SchemaComposer } from './SchemaComposer';
5import { ListComposer } from './ListComposer';
6import { NonNullComposer } from './NonNullComposer';
7import type { ThunkComposer } from './ThunkComposer';
8import type { TypeAsString, TypeDefinitionString } from './TypeMapper';
9import type { GraphQLInputFieldConfig, GraphQLInputType, InputValueDefinitionNode } from './graphql';
10import { NamedTypeComposer, ComposeInputType, ComposeNamedInputType, ComposeInputTypeDefinition } from './utils/typeHelpers';
11import { SchemaPrinterOptions } from './utils/schemaPrinter';
12export declare type InputTypeComposerDefinition = TypeAsString | TypeDefinitionString | InputTypeComposerAsObjectDefinition | Readonly<GraphQLInputObjectType>;
13export declare type InputTypeComposerAsObjectDefinition = {
14 name: string;
15 fields: ThunkWithSchemaComposer<InputTypeComposerFieldConfigMapDefinition, SchemaComposer<any>>;
16 description?: null | string;
17 extensions?: Extensions;
18 directives?: Directive[];
19};
20export declare type InputTypeComposerFieldConfigMap = ObjMap<InputTypeComposerFieldConfig>;
21export declare type InputTypeComposerFieldConfigMapDefinition = ObjMap<InputTypeComposerFieldConfigDefinition>;
22export declare type InputTypeComposerFieldConfigDefinition = ThunkWithSchemaComposer<InputTypeComposerFieldConfigAsObjectDefinition, SchemaComposer<any>> | ThunkWithSchemaComposer<ComposeInputTypeDefinition, SchemaComposer<any>>;
23export declare type InputTypeComposerFieldConfigAsObjectDefinition = {
24 type: ThunkWithSchemaComposer<ComposeInputTypeDefinition, SchemaComposer<any>>;
25 defaultValue?: unknown;
26 description?: string | null;
27 extensions?: Extensions;
28 directives?: Directive[];
29 [key: string]: unknown;
30};
31export declare type InputTypeComposerFieldConfig = {
32 type: ComposeInputType;
33 defaultValue?: unknown;
34 description?: string | null;
35 astNode?: InputValueDefinitionNode | null;
36 extensions?: Extensions;
37 directives?: Directive[];
38 [key: string]: unknown;
39};
40export declare type InputTypeComposerThunked<TContext> = InputTypeComposer<TContext> | ThunkComposer<InputTypeComposer<TContext>, GraphQLInputType>;
41export declare class InputTypeComposer<TContext = any> {
42 schemaComposer: SchemaComposer<TContext>;
43 _gqType: GraphQLInputObjectType;
44 _gqcFields: InputTypeComposerFieldConfigMap;
45 _gqcExtensions?: Extensions;
46 _gqcDirectives?: Directive[];
47 _gqcIsModified?: boolean;
48 static create<TCtx = any>(typeDef: InputTypeComposerDefinition, schemaComposer: SchemaComposer<TCtx>): InputTypeComposer<TCtx>;
49 static createTemp<TCtx = any>(typeDef: InputTypeComposerDefinition, schemaComposer?: SchemaComposer<TCtx>): InputTypeComposer<TCtx>;
50 constructor(graphqlType: GraphQLInputObjectType, schemaComposer: SchemaComposer<TContext>);
51 getFields(): InputTypeComposerFieldConfigMap;
52 getFieldNames(): string[];
53 hasField(fieldName: string): boolean;
54 setFields(fields: InputTypeComposerFieldConfigMapDefinition): this;
55 setField(fieldName: string, fieldConfig: InputTypeComposerFieldConfigDefinition): this;
56 addFields(newFields: InputTypeComposerFieldConfigMapDefinition): this;
57 addNestedFields(newFields: InputTypeComposerFieldConfigMapDefinition): this;
58 getField(fieldName: string): InputTypeComposerFieldConfig;
59 removeField(fieldNameOrArray: string | string[]): this;
60 removeOtherFields(fieldNameOrArray: string | string[]): this;
61 extendField(fieldName: string, partialFieldConfig: Partial<InputTypeComposerFieldConfigAsObjectDefinition>): this;
62 reorderFields(names: string[]): this;
63 getFieldConfig(fieldName: string): GraphQLInputFieldConfig;
64 getFieldType(fieldName: string): GraphQLInputType;
65 getFieldTypeName(fieldName: string): string;
66 getFieldTC(fieldName: string): ComposeNamedInputType<TContext>;
67 getFieldITC(fieldName: string): InputTypeComposer<TContext>;
68 isRequired(fieldName: string): boolean;
69 isFieldNonNull(fieldName: string): boolean;
70 makeFieldNonNull(fieldNameOrArray: string | string[]): this;
71 makeRequired(fieldNameOrArray: string | string[]): this;
72 makeFieldNullable(fieldNameOrArray: string | string[]): this;
73 makeOptional(fieldNameOrArray: string | string[]): this;
74 isFieldPlural(fieldName: string): boolean;
75 makeFieldPlural(fieldNameOrArray: string | string[]): this;
76 makeFieldNonPlural(fieldNameOrArray: string | string[]): this;
77 getType(): GraphQLInputObjectType;
78 getTypePlural(): ListComposer<InputTypeComposer<TContext>>;
79 getTypeNonNull(): NonNullComposer<InputTypeComposer<TContext>>;
80 get List(): ListComposer<InputTypeComposer<TContext>>;
81 get NonNull(): NonNullComposer<InputTypeComposer<TContext>>;
82 getTypeName(): string;
83 setTypeName(name: string): this;
84 getDescription(): string;
85 setDescription(description: string): this;
86 clone(newTypeNameOrTC: string | InputTypeComposer<any>): InputTypeComposer<TContext>;
87 cloneTo(anotherSchemaComposer: SchemaComposer<any>, cloneMap?: Map<any, any>): InputTypeComposer<any>;
88 merge(type: GraphQLInputObjectType | InputTypeComposer<any>): this;
89 getExtensions(): Extensions;
90 setExtensions(extensions: Extensions | undefined): this;
91 extendExtensions(extensions: Extensions): this;
92 clearExtensions(): this;
93 getExtension(extensionName: string): unknown;
94 hasExtension(extensionName: string): boolean;
95 setExtension(extensionName: string, value: unknown): this;
96 removeExtension(extensionName: string): this;
97 getFieldExtensions(fieldName: string): Extensions;
98 setFieldExtensions(fieldName: string, extensions: Extensions): this;
99 extendFieldExtensions(fieldName: string, extensions: Extensions): this;
100 clearFieldExtensions(fieldName: string): this;
101 getFieldExtension(fieldName: string, extensionName: string): unknown;
102 hasFieldExtension(fieldName: string, extensionName: string): boolean;
103 setFieldExtension(fieldName: string, extensionName: string, value: unknown): this;
104 removeFieldExtension(fieldName: string, extensionName: string): this;
105 getDirectives(): Array<Directive>;
106 setDirectives(directives: Array<Directive>): this;
107 getDirectiveNames(): string[];
108 getDirectiveByName(directiveName: string): DirectiveArgs | undefined;
109 setDirectiveByName(directiveName: string, args?: DirectiveArgs): this;
110 getDirectiveById(idx: number): DirectiveArgs | undefined;
111 getFieldDirectives(fieldName: string): Array<Directive>;
112 setFieldDirectives(fieldName: string, directives: Array<Directive> | undefined): this;
113 getFieldDirectiveNames(fieldName: string): string[];
114 getFieldDirectiveByName(fieldName: string, directiveName: string): DirectiveArgs | undefined;
115 setFieldDirectiveByName(fieldName: string, directiveName: string, args?: DirectiveArgs): this;
116 getFieldDirectiveById(fieldName: string, idx: number): DirectiveArgs | undefined;
117 get(path: string | string[]): TypeInPath<TContext> | void;
118 getNestedTCs(opts?: {
119 exclude?: string[] | null;
120 }, passedTypes?: Set<NamedTypeComposer<any>>): Set<NamedTypeComposer<any>>;
121 toSDL(opts?: SchemaPrinterOptions & {
122 deep?: boolean;
123 exclude?: string[];
124 }): string;
125}
126//# sourceMappingURL=InputTypeComposer.d.ts.map
\No newline at end of file