@@ -15,7 +15,6 @@ import {
15
15
} from 'graphql' ;
16
16
import gqlTag from 'graphql-tag' ;
17
17
import { BaseVisitor , ParsedConfig , RawConfig } from './base-visitor.js' ;
18
- import { generateFragmentImportStatement } from './imports.js' ;
19
18
import { LoadedFragment , ParsedImport } from './types.js' ;
20
19
import { buildScalarsFromConfig , getConfigValue } from './utils.js' ;
21
20
@@ -569,7 +568,7 @@ export class ClientSideBaseVisitor<
569
568
return path ;
570
569
}
571
570
572
- public getImports ( options : { excludeFragments ?: boolean } = { } ) : string [ ] {
571
+ public getImports ( ) : string [ ] {
573
572
( this . _additionalImports || [ ] ) . forEach ( i => this . _imports . add ( i ) ) ;
574
573
575
574
switch ( this . config . documentMode ) {
@@ -620,50 +619,6 @@ export class ClientSideBaseVisitor<
620
619
break ;
621
620
}
622
621
623
- if ( ! options . excludeFragments && ! this . config . globalNamespace ) {
624
- const { documentMode, fragmentImports } = this . config ;
625
- if (
626
- documentMode === DocumentMode . graphQLTag ||
627
- documentMode === DocumentMode . string ||
628
- documentMode === DocumentMode . documentNodeImportFragments
629
- ) {
630
- // keep track of what imports we've already generated so we don't try
631
- // to import the same identifier twice
632
- const alreadyImported = new Map < string , Set < string > > ( ) ;
633
-
634
- const deduplicatedImports = fragmentImports
635
- . map ( fragmentImport => {
636
- const { path, identifiers } = fragmentImport . importSource ;
637
- if ( ! alreadyImported . has ( path ) ) {
638
- alreadyImported . set ( path , new Set < string > ( ) ) ;
639
- }
640
-
641
- const alreadyImportedForPath = alreadyImported . get ( path ) ;
642
- const newIdentifiers = identifiers . filter ( identifier => ! alreadyImportedForPath . has ( identifier . name ) ) ;
643
- newIdentifiers . forEach ( newIdentifier => alreadyImportedForPath . add ( newIdentifier . name ) ) ;
644
-
645
- // filter the set of identifiers in this fragment import to only
646
- // the ones we haven't already imported from this path
647
- return {
648
- ...fragmentImport ,
649
- importSource : {
650
- ...fragmentImport . importSource ,
651
- identifiers : newIdentifiers ,
652
- } ,
653
- emitLegacyCommonJSImports : this . config . emitLegacyCommonJSImports ,
654
- } ;
655
- } )
656
- // remove any imports that now have no identifiers in them
657
- . filter ( fragmentImport => fragmentImport . importSource . identifiers . length > 0 ) ;
658
-
659
- deduplicatedImports . forEach ( fragmentImport => {
660
- if ( fragmentImport . outputPath !== fragmentImport . importSource . path ) {
661
- this . _imports . add ( generateFragmentImportStatement ( fragmentImport , 'document' ) ) ;
662
- }
663
- } ) ;
664
- }
665
- }
666
-
667
622
return Array . from ( this . _imports ) ;
668
623
}
669
624
0 commit comments