UNPKG

7.47 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 name: string;
105 fields: SelectionSetFieldNode[];
106 fragmentsSpread: SelectionSetFragmentSpread[];
107 inlineFragments: SelectionSetInlineFragment[];
108 hasFragmentsSpread: boolean;
109 hasInlineFragments: boolean;
110 hasFields: boolean;
111}
112export interface SelectionSetFragmentSpread extends SelectionSetItem {
113 fragmentName: string;
114}
115export interface SelectionSetFieldNode extends SelectionSetItem {
116 selectionSet: SelectionSetItem[];
117 name: string;
118 type: string;
119 isRequired: boolean;
120 isArray: boolean;
121 dimensionOfArray: number;
122 isNullableArray: boolean;
123 raw: string;
124 fields: SelectionSetFieldNode[];
125 fragmentsSpread: SelectionSetFragmentSpread[];
126 inlineFragments: SelectionSetInlineFragment[];
127 hasFragmentsSpread: boolean;
128 hasInlineFragments: boolean;
129 hasFields: boolean;
130 isType: boolean;
131 isScalar: boolean;
132 isInterface: boolean;
133 isUnion: boolean;
134 isInputType: boolean;
135 isEnum: boolean;
136}
137export declare function isFieldNode(node: SelectionSetItem): node is SelectionSetFieldNode;
138export declare function isFragmentSpreadNode(node: SelectionSetItem): node is SelectionSetFragmentSpread;
139export declare function isInlineFragmentNode(node: SelectionSetItem): node is SelectionSetInlineFragment;
140export interface Fragment extends AstNode {
141 name: string;
142 selectionSet: SelectionSetItem[];
143 onType: string;
144 document: string;
145 fields: SelectionSetFieldNode[];
146 fragmentsSpread: SelectionSetFragmentSpread[];
147 inlineFragments: SelectionSetInlineFragment[];
148 hasFragmentsSpread: boolean;
149 hasInlineFragments: boolean;
150 hasFields: boolean;
151 originalFile?: string;
152}
153export interface Operation extends AstNode {
154 name: string;
155 selectionSet: SelectionSetItem[];
156 operationType: string;
157 variables: Variable[];
158 hasVariables: boolean;
159 isQuery: boolean;
160 isMutation: boolean;
161 isSubscription: boolean;
162 document: string;
163 fields: SelectionSetFieldNode[];
164 fragmentsSpread: SelectionSetFragmentSpread[];
165 inlineFragments: SelectionSetInlineFragment[];
166 hasFragmentsSpread: boolean;
167 hasInlineFragments: boolean;
168 hasFields: boolean;
169 originalFile?: string;
170}
171export interface Variable {
172 name: string;
173 type: string;
174 isRequired: boolean;
175 isArray: boolean;
176 isNullableArray: boolean;
177 dimensionOfArray: number;
178 raw: string;
179 isType: boolean;
180 isScalar: boolean;
181 isInterface: boolean;
182 isUnion: boolean;
183 isInputType: boolean;
184 isEnum: boolean;
185}
186export interface Document {
187 fragments: Fragment[];
188 operations: Operation[];
189 hasFragments: boolean;
190 hasOperations: boolean;
191}
192export declare type DirectiveUseMap = {
193 [key: string]: any;
194};
195export interface Directive {
196 name: string;
197 description: string;
198 locations: string[];
199 arguments: Argument[];
200 hasArguments: boolean;
201 onFragmentSpread: boolean;
202 onInlineFragment: boolean;
203 onQuery: boolean;
204 onMutation: boolean;
205 onSubscription: boolean;
206 onFragment: boolean;
207 onField: boolean;
208 onSchema: boolean;
209 onScalar: boolean;
210 onFieldDefinition: boolean;
211 onEnum: boolean;
212 onEnumValue: boolean;
213 onObject: boolean;
214 onInputObject: boolean;
215 onInputField: boolean;
216 onArgument: boolean;
217 onInterface: boolean;
218 onUnion: boolean;
219}
220export declare const EInputType: {
221 SINGLE_FILE: string;
222 MULTIPLE_FILES: string;
223 PROJECT: string;
224};
225export interface GeneratorConfig {
226 prepend?: string[];
227 inputType: string;
228 flattenTypes: boolean;
229 config?: {
230 [configName: string]: any;
231 };
232 templates: {
233 [templateName: string]: string | string[];
234 } | string;
235 primitives: {
236 String: string;
237 Int: string;
238 Float: string;
239 Boolean: string;
240 ID: string;
241 };
242 outFile?: string;
243 filesExtension?: string;
244 customHelpers?: {
245 [helperName: string]: Function;
246 };
247 deprecationNote?: string;
248 addToSchema?: string | DocumentNode | Array<string | DocumentNode>;
249}
250export interface FileOutput {
251 filename: string;
252 content: string;
253}
254export interface Settings {
255 generateSchema?: boolean;
256 generateDocuments?: boolean;
257 verbose?: boolean;
258}
259export declare type CustomProcessingFunction = (templateContext: SchemaTemplateContext, mergedDocuments: Document, settings: any) => FileOutput[] | Promise<FileOutput[]>;
260export interface DocumentFile {
261 filePath: string;
262 content: DocumentNode;
263}
264export declare function isCustomProcessingFunction(config: GeneratorConfig | CustomProcessingFunction): config is CustomProcessingFunction;
265export declare function isGeneratorConfig(config: GeneratorConfig | CustomProcessingFunction): config is GeneratorConfig;