File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
src/main/java/com/intuit/graphql/orchestrator/batch Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 13
13
import java .util .List ;
14
14
import java .util .Map ;
15
15
import lombok .Getter ;
16
+ import lombok .ToString ;
16
17
17
18
public class DownStreamQueryOptimizer {
18
19
@@ -51,12 +52,15 @@ private static GroupedSelectionSet groupSelections(List<Selection> selections) {
51
52
}
52
53
53
54
private SelectionSet transform (SelectionSet selections ) {
54
- SelectionSet .Builder mergedSelectionSetBuilder = SelectionSet .newSelectionSet ();
55
55
final GroupedSelectionSet groupedSelectionSet = groupSelections (selections .getSelections ());
56
- groupedSelectionSet .getDistinctSelections ().forEach (selection -> mergedSelectionSetBuilder .selection (selection ));
57
- groupedSelectionSet .getGroupedFields ().values ()
58
- .forEach (fields -> mergedSelectionSetBuilder .selection (mergeFields (fields )));
59
- return mergedSelectionSetBuilder .build ();
56
+ if (groupedSelectionSet .getGroupedFields ().size () > 0 ) {
57
+ SelectionSet .Builder mergedSelectionSetBuilder = SelectionSet .newSelectionSet ();
58
+ groupedSelectionSet .getDistinctSelections ().forEach (selection -> mergedSelectionSetBuilder .selection (selection ));
59
+ groupedSelectionSet .getGroupedFields ().values ()
60
+ .forEach (fields -> mergedSelectionSetBuilder .selection (mergeFields (fields )));
61
+ return mergedSelectionSetBuilder .build ();
62
+ }
63
+ return selections ;
60
64
}
61
65
62
66
private Field mergeFields (final List <Field > fields ) {
You can’t perform that action at this time.
0 commit comments