From ae72f1afbe857e508b5a19edb3e22959c5b80a43 Mon Sep 17 00:00:00 2001 From: Nigel Sampson Date: Tue, 3 Dec 2019 15:08:51 +1300 Subject: [PATCH] Don't append __typename if it's already being selection (#1221) --- .../Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs b/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs index 9335096b171..74b96e455e5 100644 --- a/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs +++ b/src/Stitching/Stitching/Utilities/ExtractFieldQuerySyntaxRewriter.cs @@ -179,7 +179,12 @@ protected override SelectionSetNode RewriteSelectionSet( RemoveDelegationFields(current, context, selections); AddDependencies(context.TypeContext, selections, dependencies); - selections.Add(CreateField(WellKnownFieldNames.TypeName)); + + if (!selections.OfType().Any(n => n.Name.Value == WellKnownFieldNames.TypeName)) + { + selections.Add(CreateField(WellKnownFieldNames.TypeName)); + } + current = current.WithSelections(selections); current = base.RewriteSelectionSet(current, context); current = OnRewriteSelectionSet(current, context);