UNPKG

7.32 kBTypeScriptView Raw
1import { DocumentNode, GraphQLSchema } from 'graphql';
2export interface AstNode {
3 directives: DirectiveUseMap;
4 usesDirectives: boolean;
5}
6export declare type FieldType = 'Interface' | 'InputType' | 'Type' | 'Query' | 'Mutation' | 'Subscription' | 'Enum' | 'Scalar' | 'Union';
7export interface Argument extends AstNode {
8 raw: string;
9 name: string;
10 description: string;
11 type: string;
12 isRequired: boolean;
13 isArray: boolean;
14 dimensionOfArray: number;
15 isNullableArray: boolean;
16 isType: boolean;
17 isScalar: boolean;
18 isInterface: boolean;
19 isUnion: boolean;
20 isInputType: boolean;
21 isEnum: boolean;
22}
23export interface Field extends AstNode {
24 name: string;
25 description: string;
26 arguments: Argument[];
27 type: string;
28 fieldType: FieldType;
29 raw: string;
30 isArray: boolean;
31 dimensionOfArray: number;
32 isRequired: boolean;
33 isNullableArray: boolean;
34 hasArguments: boolean;
35 isType: boolean;
36 isScalar: boolean;
37 isInterface: boolean;
38 isUnion: boolean;
39 isInputType: boolean;
40 isEnum: boolean;
41}
42export interface Type extends AstNode {
43 fields: Field[];
44 description: string;
45 name: string;
46 isInputType: boolean;
47 interfaces: string[];
48 hasFields: boolean;
49 hasInterfaces: boolean;
50}
51export interface Scalar extends AstNode {
52 name: string;
53 description: string;
54}
55export interface Enum extends AstNode {
56 name: string;
57 description: string;
58 values: EnumValue[];
59}
60export interface EnumValue extends AstNode {
61 name: string;
62 value: string;
63 description: string;
64}
65export interface Union extends AstNode {
66 name: string;
67 description: string;
68 possibleTypes: string[];
69}
70export interface Interface extends AstNode {
71 name: string;
72 description: string;
73 fields: Field[];
74 hasFields: boolean;
75 implementingTypes: string[];
76 hasImplementingTypes: boolean;
77}
78export interface SchemaTemplateContext extends AstNode {
79 types: Type[];
80 inputTypes: Type[];
81 enums: Enum[];
82 unions: Union[];
83 interfaces: Interface[];
84 scalars: Scalar[];
85 definedDirectives: Directive[];
86 hasTypes: boolean;
87 hasInputTypes: boolean;
88 hasEnums: boolean;
89 hasUnions: boolean;
90 hasScalars: boolean;
91 hasInterfaces: boolean;
92 hasDefinedDirectives: boolean;
93 rawSchema: GraphQLSchema;
94}
95export interface SelectionSetItem extends AstNode {
96 isFragmentSpread: boolean;
97 isInlineFragment: boolean;
98 isField: boolean;
99 isLeaf: boolean;
100}
101export interface SelectionSetInlineFragment extends SelectionSetItem {
102 selectionSet: SelectionSetItem[];
103 onType: string;
104 fields: SelectionSetFieldNode[];
105 fragmentsSpread: SelectionSetFragmentSpread[];
106 inlineFragments: SelectionSetInlineFragment[];
107 hasFragmentsSpread: boolean;
108 hasInlineFragments: boolean;
109 hasFields: boolean;
110}
111export interface SelectionSetFragmentSpread extends SelectionSetItem {
112 fragmentName: string;
113}
114export interface SelectionSetFieldNode extends SelectionSetItem {
115 selectionSet: SelectionSetItem[];
116 name: string;
117 type: string;
118 isRequired: boolean;
119 isArray: boolean;
120 dimensionOfArray: number;
121 isNullableArray: boolean;
122 raw: string;
123 fields: SelectionSetFieldNode[];
124 fragmentsSpread: SelectionSetFragmentSpread[];
125 inlineFragments: SelectionSetInlineFragment[];
126 hasFragmentsSpread: boolean;
127 hasInlineFragments: boolean;
128 hasFields: boolean;
129 isType: boolean;
130 isScalar: boolean;
131 isInterface: boolean;
132 isUnion: boolean;
133 isInputType: boolean;
134 isEnum: boolean;
135}
136export declare function isFieldNode(node: SelectionSetItem): node is SelectionSetFieldNode;
137export declare function isFragmentSpreadNode(node: SelectionSetItem): node is SelectionSetFragmentSpread;
138export declare function isInlineFragmentNode(node: SelectionSetItem): node is SelectionSetInlineFragment;
139export interface Fragment extends AstNode {
140 name: string;
141 selectionSet: SelectionSetItem[];
142 onType: string;
143 document: string;
144 fields: SelectionSetFieldNode[];
145 fragmentsSpread: SelectionSetFragmentSpread[];
146 inlineFragments: SelectionSetInlineFragment[];
147 hasFragmentsSpread: boolean;
148 hasInlineFragments: boolean;
149 hasFields: boolean;
150}
151export interface Operation extends AstNode {
152 name: string;
153 selectionSet: SelectionSetItem[];
154 operationType: string;
155 variables: Variable[];
156 hasVariables: boolean;
157 isQuery: boolean;
158 isMutation: boolean;
159 isSubscription: boolean;
160 document: string;
161 fields: SelectionSetFieldNode[];
162 fragmentsSpread: SelectionSetFragmentSpread[];
163 inlineFragments: SelectionSetInlineFragment[];
164 hasFragmentsSpread: boolean;
165 hasInlineFragments: boolean;
166 hasFields: boolean;
167}
168export interface Variable {
169 name: string;
170 type: string;
171 isRequired: boolean;
172 isArray: boolean;
173 isNullableArray: boolean;
174 dimensionOfArray: number;
175 raw: string;
176 isType: boolean;
177 isScalar: boolean;
178 isInterface: boolean;
179 isUnion: boolean;
180 isInputType: boolean;
181 isEnum: boolean;
182}
183export interface Document {
184 fragments: Fragment[];
185 operations: Operation[];
186 hasFragments: boolean;
187 hasOperations: boolean;
188}
189export declare type DirectiveUseMap = {
190 [key: string]: any;
191};
192export interface Directive {
193 name: string;
194 description: string;
195 locations: string[];
196 arguments: Argument[];
197 hasArguments: boolean;
198 onFragmentSpread: boolean;
199 onInlineFragment: boolean;
200 onQuery: boolean;
201 onMutation: boolean;
202 onSubscription: boolean;
203 onFragment: boolean;
204 onField: boolean;
205 onSchema: boolean;
206 onScalar: boolean;
207 onFieldDefinition: boolean;
208 onEnum: boolean;
209 onEnumValue: boolean;
210 onObject: boolean;
211 onInputObject: boolean;
212 onInputField: boolean;
213 onArgument: boolean;
214 onInterface: boolean;
215 onUnion: boolean;
216}
217export declare const EInputType: {
218 SINGLE_FILE: string;
219 MULTIPLE_FILES: string;
220 PROJECT: string;
221};
222export interface GeneratorConfig {
223 prepend?: string[];
224 inputType: string;
225 flattenTypes: boolean;
226 config?: {
227 [configName: string]: any;
228 };
229 templates: {
230 [templateName: string]: string | string[];
231 } | string;
232 primitives: {
233 String: string;
234 Int: string;
235 Float: string;
236 Boolean: string;
237 ID: string;
238 };
239 outFile?: string;
240 filesExtension?: string;
241 customHelpers?: {
242 [helperName: string]: Function;
243 };
244 deprecationNote?: string;
245 addToSchema?: string | DocumentNode | Array<string | DocumentNode>;
246}
247export interface FileOutput {
248 filename: string;
249 content: string;
250}
251export interface Settings {
252 generateSchema?: boolean;
253 generateDocuments?: boolean;
254 verbose?: boolean;
255}
256export declare type CustomProcessingFunction = (templateContext: SchemaTemplateContext, mergedDocuments: Document, settings: any) => FileOutput[] | Promise<FileOutput[]>;
257export declare function isCustomProcessingFunction(config: GeneratorConfig | CustomProcessingFunction): config is CustomProcessingFunction;
258export declare function isGeneratorConfig(config: GeneratorConfig | CustomProcessingFunction): config is GeneratorConfig;