UNPKG

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