UNPKG

7.46 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 Document {
186 fragments: Fragment[];
187 operations: Operation[];
188 hasFragments: boolean;
189 hasOperations: boolean;
190}
191export declare type DirectiveUseMap = {
192 [key: string]: any;
193};
194export interface Directive {
195 name: string;
196 description: string;
197 locations: string[];
198 arguments: Argument[];
199 hasArguments: boolean;
200 onFragmentSpread: boolean;
201 onInlineFragment: boolean;
202 onQuery: boolean;
203 onMutation: boolean;
204 onSubscription: boolean;
205 onFragment: boolean;
206 onField: boolean;
207 onSchema: boolean;
208 onScalar: boolean;
209 onFieldDefinition: boolean;
210 onEnum: boolean;
211 onEnumValue: boolean;
212 onObject: boolean;
213 onInputObject: boolean;
214 onInputField: boolean;
215 onArgument: boolean;
216 onInterface: boolean;
217 onUnion: boolean;
218}
219export declare const EInputType: {
220 SINGLE_FILE: string;
221 MULTIPLE_FILES: string;
222 PROJECT: string;
223};
224export interface GeneratorConfig {
225 prepend?: string[];
226 inputType: string;
227 flattenTypes: boolean;
228 config?: {
229 [configName: string]: any;
230 };
231 templates: {
232 [templateName: string]: string | string[];
233 } | string;
234 primitives: {
235 String: string;
236 Int: string;
237 Float: string;
238 Boolean: string;
239 ID: string;
240 };
241 outFile?: string;
242 filesExtension?: string;
243 customHelpers?: {
244 [helperName: string]: Function;
245 };
246 deprecationNote?: string;
247 addToSchema?: string | DocumentNode | Array<string | DocumentNode>;
248}
249export interface FileOutput {
250 filename: string;
251 content: string;
252}
253export interface Settings {
254 generateSchema?: boolean;
255 generateDocuments?: boolean;
256 verbose?: boolean;
257}
258export declare type CustomProcessingFunction = (templateContext: SchemaTemplateContext, mergedDocuments: Document, settings: any) => FileOutput[] | Promise<FileOutput[]>;
259export interface DocumentFile {
260 filePath: string;
261 content: DocumentNode;
262}
263export declare function isCustomProcessingFunction(config: GeneratorConfig | CustomProcessingFunction): config is CustomProcessingFunction;
264export declare function isGeneratorConfig(config: GeneratorConfig | CustomProcessingFunction): config is GeneratorConfig;