@@ -7,7 +7,7 @@ use std::time::{Duration, Instant};
7
7
use crate :: prelude:: { QueryExecutionOptions , StoreResolver , SubscriptionExecutionOptions } ;
8
8
use crate :: query:: execute_query;
9
9
use crate :: subscription:: execute_prepared_subscription;
10
- use graph:: prelude:: { MetricsRegistry , QueryResult } ;
10
+ use graph:: prelude:: MetricsRegistry ;
11
11
use graph:: prometheus:: { Gauge , Histogram } ;
12
12
use graph:: {
13
13
components:: store:: SubscriptionManager ,
@@ -22,10 +22,10 @@ use graph::{
22
22
prelude:: QueryStore ,
23
23
} ;
24
24
use graphql_tools:: validation:: rules:: {
25
- FragmentsOnCompositeTypes , KnownFragmentNamesRule , LoneAnonymousOperation , NoUnusedFragments ,
26
- OverlappingFieldsCanBeMerged ,
25
+ FragmentsOnCompositeTypes , KnownFragmentNamesRule , LeafFieldSelections , LoneAnonymousOperation ,
26
+ NoUnusedFragments , OverlappingFieldsCanBeMerged ,
27
27
} ;
28
- use graphql_tools:: validation:: validate:: { validate , ValidationPlan } ;
28
+ use graphql_tools:: validation:: validate:: ValidationPlan ;
29
29
30
30
use lazy_static:: lazy_static;
31
31
@@ -82,7 +82,7 @@ pub struct GraphQlRunner<S, SM> {
82
82
subscription_manager : Arc < SM > ,
83
83
load_manager : Arc < LoadManager > ,
84
84
result_size : Arc < ResultSizeMetrics > ,
85
- graphql_validation_plan : ValidationPlan ,
85
+ pub graphql_validation_plan : Arc < ValidationPlan > ,
86
86
}
87
87
88
88
lazy_static ! {
@@ -148,14 +148,15 @@ where
148
148
graphql_validation_plan. add_rule ( Box :: new ( OverlappingFieldsCanBeMerged { } ) ) ;
149
149
graphql_validation_plan. add_rule ( Box :: new ( KnownFragmentNamesRule { } ) ) ;
150
150
graphql_validation_plan. add_rule ( Box :: new ( NoUnusedFragments { } ) ) ;
151
+ graphql_validation_plan. add_rule ( Box :: new ( LeafFieldSelections { } ) ) ;
151
152
152
153
GraphQlRunner {
153
154
logger,
154
155
store,
155
156
subscription_manager,
156
157
load_manager,
157
158
result_size,
158
- graphql_validation_plan,
159
+ graphql_validation_plan : Arc :: new ( graphql_validation_plan ) ,
159
160
}
160
161
}
161
162
@@ -210,17 +211,6 @@ where
210
211
// setting up here
211
212
let store = self . store . query_store ( target, false ) . await ?;
212
213
let schema = store. api_schema ( ) ?;
213
-
214
- let validation_errors = validate (
215
- & schema. document ( ) ,
216
- & query. document ,
217
- & self . graphql_validation_plan ,
218
- ) ;
219
-
220
- if validation_errors. len ( ) > 0 {
221
- return Ok ( QueryResults :: from ( QueryResult :: from ( validation_errors) ) ) ;
222
- }
223
-
224
214
let state = store. deployment_state ( ) . await ?;
225
215
let network = Some ( store. network_name ( ) . to_string ( ) ) ;
226
216
@@ -238,6 +228,7 @@ where
238
228
schema,
239
229
network,
240
230
query,
231
+ self . graphql_validation_plan . clone ( ) ,
241
232
max_complexity,
242
233
max_depth,
243
234
) ?;
@@ -343,6 +334,7 @@ where
343
334
schema,
344
335
Some ( network. clone ( ) ) ,
345
336
subscription. query ,
337
+ self . graphql_validation_plan . clone ( ) ,
346
338
* GRAPHQL_MAX_COMPLEXITY ,
347
339
* GRAPHQL_MAX_DEPTH ,
348
340
) ?;
0 commit comments