File tree Expand file tree Collapse file tree
other/visitor-plugin-common/src
typescript/operations/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -371,15 +371,22 @@ export class BaseDocumentsVisitor<
371371 } )
372372 ) ;
373373
374- const operationResult = new DeclarationBlock ( this . _declarationBlockConfig )
375- . export ( )
376- . asKind ( 'type' )
377- . withName (
378- this . convertName ( name , {
379- suffix : operationTypeSuffix + this . _parsedConfig . operationResultSuffix ,
380- } )
381- )
382- . withContent ( selectionSetObjects . mergedTypeString ) . string ;
374+ const operationResultName = this . convertName ( name , {
375+ suffix : operationTypeSuffix + this . _parsedConfig . operationResultSuffix ,
376+ } ) ;
377+
378+ // When extractAllFieldsToTypes creates a root type with the same name as the operation result,
379+ // we only need the extracted type and can skip the alias to avoid duplicates
380+ const shouldSkipOperationResult =
381+ this . _parsedConfig . extractAllFieldsToTypes && operationResultName === selectionSetObjects . mergedTypeString ;
382+
383+ const operationResult = shouldSkipOperationResult
384+ ? ''
385+ : new DeclarationBlock ( this . _declarationBlockConfig )
386+ . export ( )
387+ . asKind ( 'type' )
388+ . withName ( operationResultName )
389+ . withContent ( selectionSetObjects . mergedTypeString ) . string ;
383390
384391 const operationVariables = new DeclarationBlock ( {
385392 ...this . _declarationBlockConfig ,
Original file line number Diff line number Diff line change @@ -1562,9 +1562,6 @@ describe('extractAllFieldsToTypesCompact: true', () => {
15621562 export type GetCompanyInfoVariables = Exact<{
15631563 id: string;
15641564 }>;
1565-
1566-
1567- export type GetCompanyInfo = GetCompanyInfo;
15681565 "
15691566 ` ) ;
15701567
You can’t perform that action at this time.
0 commit comments