@@ -96,17 +96,6 @@ private Single<EntityRequest> build(
9696 .count ()
9797 > 0 ;
9898
99- boolean canFetchLabels =
100- this .selectionFinder
101- .findSelections (
102- selectionSet ,
103- SelectionQuery .builder ()
104- .selectionPath (
105- List .of (ResultSet .RESULT_SET_RESULTS_NAME , Entity .LABELS_KEY ))
106- .build ())
107- .count ()
108- > 0 ;
109-
11099 return zip (
111100 this .resultSetRequestBuilder .build (
112101 context , scope , arguments , selectionSet , AggregatableOrderArgument .class ),
@@ -121,7 +110,7 @@ private Single<EntityRequest> build(
121110 this .timeRange (arguments ),
122111 this .space (arguments ),
123112 this .getOutgoingEdges (selectionSet )),
124- attributeRequestBuilder . buildForKey (context , scope , LABELS_KEY_NAME ),
113+ buildLabelRequest (context , scope , selectionSet ),
125114 (resultSetRequest ,
126115 metricRequestList ,
127116 incomingEdges ,
@@ -135,9 +124,28 @@ private Single<EntityRequest> build(
135124 outgoingEdges ,
136125 includeInactive ,
137126 fetchTotal ,
138- canFetchLabels
139- ? Optional .of (new DefaultLabelRequest (labelsAttributeRequest ))
140- : Optional .empty ()));
127+ labelsAttributeRequest ));
128+ }
129+
130+ private Single <Optional <LabelRequest >> buildLabelRequest (
131+ GraphQlRequestContext context , String scope , DataFetchingFieldSelectionSet selectionSet ) {
132+ boolean canFetchLabels =
133+ this .selectionFinder
134+ .findSelections (
135+ selectionSet ,
136+ SelectionQuery .builder ()
137+ .selectionPath (
138+ List .of (ResultSet .RESULT_SET_RESULTS_NAME , Entity .LABELS_KEY ))
139+ .build ())
140+ .count ()
141+ > 0 ;
142+
143+ return canFetchLabels
144+ ? attributeRequestBuilder
145+ .buildForKey (context , scope , LABELS_KEY_NAME )
146+ .map (DefaultLabelRequest ::new )
147+ .map (Optional ::of )
148+ : Single .just (Optional .empty ());
141149 }
142150
143151 private Stream <SelectedField > getResultSets (DataFetchingFieldSelectionSet selectionSet ) {
0 commit comments