@@ -165,7 +165,10 @@ class Parser {
165
165
}
166
166
const importDoc = parse ( importSource , this . _resolver , this . _options ) ;
167
167
if ( imp . all ) {
168
- importDoc . definitions . map ( ( def ) => defs . push ( def ) ) ;
168
+ importDoc . definitions . map ( ( def ) => {
169
+ def . imported = true ;
170
+ defs . push ( def ) ;
171
+ } ) ;
169
172
} else {
170
173
const allDefs = new Map < string , Definition > ( ) ;
171
174
importDoc . definitions . map ( ( def ) => {
@@ -205,65 +208,65 @@ class Parser {
205
208
switch ( def . getKind ( ) ) {
206
209
case Kind . TypeDefinition :
207
210
const type = def as TypeDefinition ;
208
- defs . push (
209
- new TypeDefinition (
210
- name . loc ,
211
- name ,
212
- type . description ,
213
- type . interfaces ,
214
- type . annotations ,
215
- type . fields
216
- )
211
+ const renamedType = new TypeDefinition (
212
+ name . loc ,
213
+ name ,
214
+ type . description ,
215
+ type . interfaces ,
216
+ type . annotations ,
217
+ type . fields
217
218
) ;
219
+ renamedType . imported = true ;
220
+ defs . push ( renamedType ) ;
218
221
break ;
219
222
case Kind . EnumDefinition :
220
223
const enumDef = def as EnumDefinition ;
221
- defs . push (
222
- new EnumDefinition (
223
- name . loc ,
224
- name ,
225
- enumDef . description ,
226
- enumDef . annotations ,
227
- enumDef . values
228
- )
224
+ const renamedEnum = new EnumDefinition (
225
+ name . loc ,
226
+ name ,
227
+ enumDef . description ,
228
+ enumDef . annotations ,
229
+ enumDef . values
229
230
) ;
231
+ renamedEnum . imported = true ;
232
+ defs . push ( renamedEnum ) ;
230
233
break ;
231
234
case Kind . UnionDefinition :
232
235
const unionDef = def as UnionDefinition ;
233
- defs . push (
234
- new UnionDefinition (
235
- name . loc ,
236
- name ,
237
- unionDef . description ,
238
- unionDef . annotations ,
239
- unionDef . types
240
- )
236
+ const renamedUnion = new UnionDefinition (
237
+ name . loc ,
238
+ name ,
239
+ unionDef . description ,
240
+ unionDef . annotations ,
241
+ unionDef . types
241
242
) ;
243
+ renamedUnion . imported = true ;
244
+ defs . push ( renamedUnion ) ;
242
245
break ;
243
246
case Kind . DirectiveDefinition :
244
247
const directive = def as DirectiveDefinition ;
245
- defs . push (
246
- new DirectiveDefinition (
247
- name . loc ,
248
- name ,
249
- directive . description ,
250
- directive . parameters ,
251
- directive . locations ,
252
- directive . requires
253
- )
248
+ const renamedDirective = new DirectiveDefinition (
249
+ name . loc ,
250
+ name ,
251
+ directive . description ,
252
+ directive . parameters ,
253
+ directive . locations ,
254
+ directive . requires
254
255
) ;
256
+ renamedDirective . imported = true ;
257
+ defs . push ( renamedDirective ) ;
255
258
break ;
256
259
case Kind . AliasDefinition :
257
260
const alias = def as AliasDefinition ;
258
- defs . push (
259
- new AliasDefinition (
260
- name . loc ,
261
- name ,
262
- alias . description ,
263
- alias . type ,
264
- alias . annotations
265
- )
261
+ const renamedAlias = new AliasDefinition (
262
+ name . loc ,
263
+ name ,
264
+ alias . description ,
265
+ alias . type ,
266
+ alias . annotations
266
267
) ;
268
+ renamedAlias . imported = true ;
269
+ defs . push ( renamedAlias ) ;
267
270
break ;
268
271
}
269
272
} ) ;
@@ -565,7 +568,7 @@ class Parser {
565
568
* - EnumTypeDefinition
566
569
* - InputObjectTypeDefinition
567
570
*/
568
- parseTypeSystemDefinition ( ) : Node {
571
+ parseTypeSystemDefinition ( ) : Definition {
569
572
// Many definitions begin with a description and require a lookahead.
570
573
const keywordToken = this . peekDescription ( )
571
574
? this . _lexer . lookahead ( )
@@ -590,7 +593,7 @@ class Parser {
590
593
case "interface" :
591
594
return this . parseInterfaceDefinition ( ) ;
592
595
case "role" :
593
- return this . parseRoleTypeDefinition ( ) ;
596
+ return this . parseRoleDefinition ( ) ;
594
597
case "type" :
595
598
return this . parseTypeDefinition ( ) ;
596
599
case "union" :
@@ -603,7 +606,7 @@ class Parser {
603
606
throw this . unexpected ( keywordToken ) ;
604
607
}
605
608
606
- parseNamespaceDefinition ( ) : Node {
609
+ parseNamespaceDefinition ( ) : NamespaceDefinition {
607
610
let start = this . _lexer . token ;
608
611
const description = this . parseDescription ( ) ;
609
612
this . expectKeyword ( "namespace" ) ;
@@ -629,7 +632,7 @@ class Parser {
629
632
) ;
630
633
}
631
634
632
- parseImportDefinition ( ) : Node {
635
+ parseImportDefinition ( ) : ImportDefinition {
633
636
let start = this . _lexer . token ;
634
637
const description = this . parseDescription ( ) ;
635
638
this . expectKeyword ( "import" ) ;
@@ -663,7 +666,7 @@ class Parser {
663
666
) ;
664
667
}
665
668
666
- parseAliasDefinition ( ) : Node {
669
+ parseAliasDefinition ( ) : AliasDefinition {
667
670
let start = this . _lexer . token ;
668
671
const description = this . parseDescription ( ) ;
669
672
this . expectKeyword ( "alias" ) ;
@@ -711,7 +714,7 @@ class Parser {
711
714
* Description?
712
715
* type Name ImplementsInterfaces? Annotations[Const]? FieldsDefinition?
713
716
*/
714
- parseTypeDefinition ( ) : Node {
717
+ parseTypeDefinition ( ) : TypeDefinition {
715
718
const start = this . _lexer . token ;
716
719
const description = this . parseDescription ( ) ;
717
720
this . expectKeyword ( "type" ) ;
@@ -857,7 +860,7 @@ class Parser {
857
860
* InterfaceTypeDefinition :
858
861
* - Description? interface Name Annotations[Const]? FieldsDefinition?
859
862
*/
860
- parseInterfaceDefinition ( ) : Node {
863
+ parseInterfaceDefinition ( ) : InterfaceDefinition {
861
864
const start = this . _lexer . token ;
862
865
const description = this . parseDescription ( ) ;
863
866
this . expectKeyword ( "interface" ) ; // TODO
@@ -880,7 +883,7 @@ class Parser {
880
883
* InterfaceTypeDefinition :
881
884
* - Description? interface Name Annotations[Const]? FieldsDefinition?
882
885
*/
883
- parseRoleTypeDefinition ( ) : Node {
886
+ parseRoleDefinition ( ) : RoleDefinition {
884
887
const start = this . _lexer . token ;
885
888
const description = this . parseDescription ( ) ;
886
889
this . expectKeyword ( "role" ) ;
@@ -905,7 +908,7 @@ class Parser {
905
908
* UnionTypeDefinition :
906
909
* - Description? union Name Annotations[Const]? UnionMemberTypes?
907
910
*/
908
- parseUnionDefinition ( ) : Node {
911
+ parseUnionDefinition ( ) : UnionDefinition {
909
912
const start = this . _lexer . token ;
910
913
const description = this . parseDescription ( ) ;
911
914
this . expectKeyword ( "union" ) ;
@@ -940,7 +943,7 @@ class Parser {
940
943
* EnumDefinition :
941
944
* - Description? enum Name Annotations[Const]? EnumValuesDefinition?
942
945
*/
943
- parseEnumDefinition ( ) : Node {
946
+ parseEnumDefinition ( ) : EnumDefinition {
944
947
const start = this . _lexer . token ;
945
948
const description = this . parseDescription ( ) ;
946
949
this . expectKeyword ( "enum" ) ;
0 commit comments