Skip to content

Commit

Permalink
fix loop issue
Browse files Browse the repository at this point in the history
  • Loading branch information
srolel committed Oct 24, 2022
1 parent f6cfaed commit b36eab3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/wrap/src/transforms/TransformCompositeFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default class TransformCompositeFields<TContext = Record<string, any>>

const parentTypeName = parentType.name;
let newSelections: Array<SelectionNode> = [];
let addedTypeNameAlready = false

for (const selection of node.selections) {
if (selection.kind !== Kind.FIELD) {
Expand All @@ -148,8 +149,8 @@ export default class TransformCompositeFields<TContext = Record<string, any>>

// See https://github.com/ardatan/graphql-tools/issues/2282
if (
(this.dataTransformer != null || this.errorsTransformer != null) &&
(this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName)
(!addedTypeNameAlready && (this.dataTransformer != null || this.errorsTransformer != null) &&
(this.subscriptionTypeName == null || parentTypeName !== this.subscriptionTypeName))
) {
newSelections.push({
kind: Kind.FIELD,
Expand All @@ -158,6 +159,7 @@ export default class TransformCompositeFields<TContext = Record<string, any>>
value: '__typename',
},
});
addedTypeNameAlready = true;
}

let transformedSelection: Maybe<SelectionNode | Array<SelectionNode>>;
Expand Down

0 comments on commit b36eab3

Please sign in to comment.