UNPKG

6.65 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 hasDefaultValue: boolean;
23}
24export interface Field extends AstNode {
25 name: string;
26 description: string;
27 arguments: Argument[];
28 type: string;
29 fieldType: FieldType;
30 raw: string;
31 isArray: boolean;
32 dimensionOfArray: number;
33 isRequired: boolean;
34 isNullableArray: boolean;
35 hasArguments: boolean;
36 hasDefaultValue: boolean;
37 isType: boolean;
38 isScalar: boolean;
39 isInterface: boolean;
40 isUnion: boolean;
41 isInputType: boolean;
42 isEnum: boolean;
43}
44export interface Type extends AstNode {
45 fields: Field[];
46 description: string;
47 name: string;
48 isInputType: boolean;
49 interfaces: string[];
50 hasFields: boolean;
51 hasInterfaces: boolean;
52}
53export interface Scalar extends AstNode {
54 name: string;
55 description: string;
56}
57export interface Enum extends AstNode {
58 name: string;
59 description: string;
60 values: EnumValue[];
61}
62export interface EnumValue extends AstNode {
63 name: string;
64 value: string;
65 description: string;
66}
67export interface Union extends AstNode {
68 name: string;
69 description: string;
70 possibleTypes: string[];
71}
72export interface Interface extends AstNode {
73 name: string;
74 description: string;
75 fields: Field[];
76 hasFields: boolean;
77 implementingTypes: string[];
78 hasImplementingTypes: boolean;
79}
80export interface SchemaTemplateContext extends AstNode {
81 types: Type[];
82 inputTypes: Type[];
83 enums: Enum[];
84 unions: Union[];
85 interfaces: Interface[];
86 scalars: Scalar[];
87 definedDirectives: Directive[];
88 hasTypes: boolean;
89 hasInputTypes: boolean;
90 hasEnums: boolean;
91 hasUnions: boolean;
92 hasScalars: boolean;
93 hasInterfaces: boolean;
94 hasDefinedDirectives: boolean;
95 rawSchema: GraphQLSchema;
96}
97export interface SelectionSetItem extends AstNode {
98 isFragmentSpread: boolean;
99 isInlineFragment: boolean;
100 isField: boolean;
101 isLeaf: boolean;
102}
103export interface SelectionSetInlineFragment extends SelectionSetItem {
104 selectionSet: SelectionSetItem[];
105 onType: string;
106 name: string;
107 fields: SelectionSetFieldNode[];
108 fragmentsSpread: SelectionSetFragmentSpread[];
109 inlineFragments: SelectionSetInlineFragment[];
110 hasFragmentsSpread: boolean;
111 hasInlineFragments: boolean;
112 hasFields: boolean;
113 hasTypename: boolean;
114}
115export interface SelectionSetFragmentSpread extends SelectionSetItem {
116 fragmentName: string;
117}
118export interface SelectionSetFieldNode extends SelectionSetItem {
119 selectionSet: SelectionSetItem[];
120 name: string;
121 isAliased: boolean;
122 schemaFieldName: string;
123 type: string;
124 isRequired: boolean;
125 isArray: boolean;
126 dimensionOfArray: number;
127 isNullableArray: boolean;
128 raw: string;
129 fields: SelectionSetFieldNode[];
130 fragmentsSpread: SelectionSetFragmentSpread[];
131 inlineFragments: SelectionSetInlineFragment[];
132 hasFragmentsSpread: boolean;
133 hasInlineFragments: boolean;
134 hasFields: boolean;
135 hasTypename: boolean;
136 isType: boolean;
137 isScalar: boolean;
138 isInterface: boolean;
139 isUnion: boolean;
140 isInputType: boolean;
141 isEnum: boolean;
142}
143export declare function isFieldNode(node: SelectionSetItem): node is SelectionSetFieldNode;
144export declare function isFragmentSpreadNode(node: SelectionSetItem): node is SelectionSetFragmentSpread;
145export declare function isInlineFragmentNode(node: SelectionSetItem): node is SelectionSetInlineFragment;
146export interface Fragment extends AstNode {
147 name: string;
148 selectionSet: SelectionSetItem[];
149 onType: string;
150 document: string;
151 fields: SelectionSetFieldNode[];
152 fragmentsSpread: SelectionSetFragmentSpread[];
153 inlineFragments: SelectionSetInlineFragment[];
154 hasFragmentsSpread: boolean;
155 hasInlineFragments: boolean;
156 hasFields: boolean;
157 originalFile?: string;
158}
159export interface Operation extends AstNode {
160 name: string;
161 selectionSet: SelectionSetItem[];
162 operationType: string;
163 variables: Variable[];
164 hasVariables: boolean;
165 isQuery: boolean;
166 isMutation: boolean;
167 isSubscription: boolean;
168 document: string;
169 fields: SelectionSetFieldNode[];
170 fragmentsSpread: SelectionSetFragmentSpread[];
171 inlineFragments: SelectionSetInlineFragment[];
172 hasFragmentsSpread: boolean;
173 hasInlineFragments: boolean;
174 hasFields: boolean;
175 originalFile?: string;
176}
177export interface Variable {
178 name: string;
179 type: string;
180 isRequired: boolean;
181 isArray: boolean;
182 isNullableArray: boolean;
183 dimensionOfArray: number;
184 raw: string;
185 isType: boolean;
186 isScalar: boolean;
187 isInterface: boolean;
188 isUnion: boolean;
189 isInputType: boolean;
190 isEnum: boolean;
191}
192export interface Document {
193 fragments: Fragment[];
194 operations: Operation[];
195 hasFragments: boolean;
196 hasOperations: boolean;
197}
198export declare type DirectiveUseMap = {
199 [key: string]: any;
200};
201export interface Directive {
202 name: string;
203 description: string;
204 locations: string[];
205 arguments: Argument[];
206 hasArguments: boolean;
207 onFragmentSpread: boolean;
208 onInlineFragment: boolean;
209 onQuery: boolean;
210 onMutation: boolean;
211 onSubscription: boolean;
212 onFragment: boolean;
213 onField: boolean;
214 onSchema: boolean;
215 onScalar: boolean;
216 onFieldDefinition: boolean;
217 onEnum: boolean;
218 onEnumValue: boolean;
219 onObject: boolean;
220 onInputObject: boolean;
221 onInputField: boolean;
222 onArgument: boolean;
223 onInterface: boolean;
224 onUnion: boolean;
225}
226export interface FileOutput {
227 filename: string;
228 content: string;
229}
230export interface Settings {
231 generateSchema?: boolean;
232 generateDocuments?: boolean;
233 verbose?: boolean;
234}
235export declare type CustomProcessingFunction = (templateContext: SchemaTemplateContext, mergedDocuments: Document, settings: any) => FileOutput[] | Promise<FileOutput[]>;
236export interface DocumentFile {
237 filePath: string;
238 content: DocumentNode;
239}