UNPKG

7.64 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 originalFile?: string;
151}
152export interface Operation extends AstNode {
153 name: string;
154 selectionSet: SelectionSetItem[];
155 operationType: string;
156 variables: Variable[];
157 hasVariables: boolean;
158 isQuery: boolean;
159 isMutation: boolean;
160 isSubscription: boolean;
161 document: string;
162 fields: SelectionSetFieldNode[];
163 fragmentsSpread: SelectionSetFragmentSpread[];
164 inlineFragments: SelectionSetInlineFragment[];
165 hasFragmentsSpread: boolean;
166 hasInlineFragments: boolean;
167 hasFields: boolean;
168 originalFile?: string;
169}
170export interface Variable {
171 name: string;
172 type: string;
173 isRequired: boolean;
174 isArray: boolean;
175 isNullableArray: boolean;
176 dimensionOfArray: number;
177 raw: string;
178 isType: boolean;
179 isScalar: boolean;
180 isInterface: boolean;
181 isUnion: boolean;
182 isInputType: boolean;
183 isEnum: boolean;
184}
185export interface TemplateDocumentFileReference {
186 relative: string;
187 absolute: string;
188 cwd: string;
189 filename: string;
190 extension: string;
191 documents: AstNode[];
192}
193export interface Document {
194 fragments: Fragment[];
195 operations: Operation[];
196 hasFragments: boolean;
197 hasOperations: boolean;
198}
199export declare type DirectiveUseMap = {
200 [key: string]: any;
201};
202export interface Directive {
203 name: string;
204 description: string;
205 locations: string[];
206 arguments: Argument[];
207 hasArguments: boolean;
208 onFragmentSpread: boolean;
209 onInlineFragment: boolean;
210 onQuery: boolean;
211 onMutation: boolean;
212 onSubscription: boolean;
213 onFragment: boolean;
214 onField: boolean;
215 onSchema: boolean;
216 onScalar: boolean;
217 onFieldDefinition: boolean;
218 onEnum: boolean;
219 onEnumValue: boolean;
220 onObject: boolean;
221 onInputObject: boolean;
222 onInputField: boolean;
223 onArgument: boolean;
224 onInterface: boolean;
225 onUnion: boolean;
226}
227export declare const EInputType: {
228 SINGLE_FILE: string;
229 MULTIPLE_FILES: string;
230 PROJECT: string;
231};
232export interface GeneratorConfig {
233 prepend?: string[];
234 inputType: string;
235 flattenTypes: boolean;
236 config?: {
237 [configName: string]: any;
238 };
239 templates: {
240 [templateName: string]: string | string[];
241 } | string;
242 primitives: {
243 String: string;
244 Int: string;
245 Float: string;
246 Boolean: string;
247 ID: string;
248 };
249 outFile?: string;
250 filesExtension?: string;
251 customHelpers?: {
252 [helperName: string]: Function;
253 };
254 deprecationNote?: string;
255 addToSchema?: string | DocumentNode | Array<string | DocumentNode>;
256}
257export interface FileOutput {
258 filename: string;
259 content: string;
260}
261export interface Settings {
262 generateSchema?: boolean;
263 generateDocuments?: boolean;
264 verbose?: boolean;
265}
266export declare type CustomProcessingFunction = (templateContext: SchemaTemplateContext, mergedDocuments: Document, settings: any) => FileOutput[] | Promise<FileOutput[]>;
267export interface DocumentFile {
268 filePath: string;
269 content: DocumentNode;
270}
271export declare function isCustomProcessingFunction(config: GeneratorConfig | CustomProcessingFunction): config is CustomProcessingFunction;
272export declare function isGeneratorConfig(config: GeneratorConfig | CustomProcessingFunction): config is GeneratorConfig;