@@ -50,7 +50,6 @@ import {
5050 SCALARS ,
5151 TypeScriptOperationVariablesToObject ,
5252} from './ts-operation-variables-to-object.js' ;
53- import { TypeScriptSelectionSetProcessor } from './ts-selection-set-processor.js' ;
5453
5554export interface TypeScriptDocumentsParsedConfig extends ParsedDocumentsConfig {
5655 arrayInputCoercion : boolean ;
@@ -92,7 +91,6 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
9291 avoidOptionals : normalizeAvoidOptionals ( getConfigValue ( config . avoidOptionals , false ) ) ,
9392 immutableTypes : getConfigValue ( config . immutableTypes , false ) ,
9493 nonOptionalTypename : getConfigValue ( config . nonOptionalTypename , false ) ,
95- preResolveTypes : getConfigValue ( config . preResolveTypes , true ) ,
9694 mergeFragmentTypes : getConfigValue ( config . mergeFragmentTypes , false ) ,
9795 allowUndefinedQueryVariables : getConfigValue ( config . allowUndefinedQueryVariables , false ) ,
9896 enumType : getConfigValue ( config . enumType , 'string-literal' ) ,
@@ -109,22 +107,9 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
109107 this . _outputPath = outputPath ;
110108 autoBind ( this ) ;
111109
112- const preResolveTypes = getConfigValue ( config . preResolveTypes , true ) ;
113110 const defaultMaybeValue = 'T | null' ;
114111 const maybeValue = getConfigValue ( config . maybeValue , defaultMaybeValue ) ;
115112
116- const wrapOptional = ( type : string ) => {
117- if ( preResolveTypes === true ) {
118- return maybeValue . replace ( 'T' , type ) ;
119- }
120- const prefix = this . config . namespacedImportName ? `${ this . config . namespacedImportName } .` : '' ;
121- return `${ prefix } Maybe<${ type } >` ;
122- } ;
123- const wrapArray = ( type : string ) => {
124- const listModifier = this . config . immutableTypes ? 'ReadonlyArray' : 'Array' ;
125- return `${ listModifier } <${ type } >` ;
126- } ;
127-
128113 const allFragments : LoadedFragment [ ] = [
129114 ...(
130115 documentNode . definitions . filter (
@@ -150,17 +135,18 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor<
150135 formatNamedField : ( { name, isOptional } ) => {
151136 return ( this . config . immutableTypes ? `readonly ${ name } ` : name ) + ( isOptional ? '?' : '' ) ;
152137 } ,
153- wrapTypeWithModifiers ( baseType , type ) {
138+ wrapTypeWithModifiers : ( baseType , type ) => {
154139 return wrapTypeWithModifiers ( baseType , type , {
155- wrapOptional,
156- wrapArray,
140+ wrapOptional : type => maybeValue . replace ( 'T' , type ) ,
141+ wrapArray : type => {
142+ const listModifier = this . config . immutableTypes ? 'ReadonlyArray' : 'Array' ;
143+ return `${ listModifier } <${ type } >` ;
144+ } ,
157145 } ) ;
158146 } ,
159147 printFieldsOnNewLines : this . config . printFieldsOnNewLines ,
160148 } ;
161- const processor = new (
162- preResolveTypes ? PreResolveTypesProcessor : TypeScriptSelectionSetProcessor
163- ) ( processorConfig ) ;
149+ const processor = new PreResolveTypesProcessor ( processorConfig ) ;
164150 this . setSelectionSetHandler (
165151 new SelectionSetToObject (
166152 processor ,
0 commit comments