@@ -127,6 +127,14 @@ where
127
127
) -> Result < QueryResult , Vec < QueryExecutionError > > {
128
128
let max_depth = max_depth. unwrap_or ( * GRAPHQL_MAX_DEPTH ) ;
129
129
let query = crate :: execution:: Query :: new ( query, max_complexity, max_depth) ?;
130
+
131
+ if self
132
+ . load_manager
133
+ . decline ( query. shape_hash , query. query_text . as_ref ( ) )
134
+ {
135
+ return Err ( vec ! [ QueryExecutionError :: TooExpensive ] ) ;
136
+ }
137
+
130
138
let mut values = BTreeMap :: new ( ) ;
131
139
let mut errors = Vec :: new ( ) ;
132
140
for ( bc, selection_set) in query. block_constraint ( ) ? {
@@ -154,14 +162,6 @@ where
154
162
Ok ( QueryResult :: new ( Some ( q:: Value :: Object ( values) ) ) )
155
163
}
156
164
}
157
-
158
- pub fn check_too_expensive ( & self , query : & Query ) -> Result < ( ) , Vec < QueryExecutionError > > {
159
- if self . load_manager . decline ( query. shape_hash ) {
160
- Err ( vec ! [ QueryExecutionError :: TooExpensive ] )
161
- } else {
162
- Ok ( ( ) )
163
- }
164
- }
165
165
}
166
166
167
167
impl < S > GraphQlRunnerTrait for GraphQlRunner < S >
@@ -185,18 +185,12 @@ where
185
185
max_first : Option < u32 > ,
186
186
) -> QueryResultFuture {
187
187
let result = self
188
- . check_too_expensive ( & query)
189
- . and_then ( |_| self . execute ( query, max_complexity, max_depth, max_first) )
188
+ . execute ( query, max_complexity, max_depth, max_first)
190
189
. unwrap_or_else ( |e| QueryResult :: from ( e) ) ;
191
190
Box :: new ( future:: ok ( result) )
192
191
}
193
192
194
193
fn run_subscription ( & self , subscription : Subscription ) -> SubscriptionResultFuture {
195
- if let Err ( errs) = self . check_too_expensive ( & subscription. query ) {
196
- let err = SubscriptionError :: GraphQLError ( errs) ;
197
- return Box :: new ( future:: result ( Err ( err) ) ) ;
198
- }
199
-
200
194
let query = match crate :: execution:: Query :: new (
201
195
subscription. query ,
202
196
* GRAPHQL_MAX_COMPLEXITY ,
@@ -206,6 +200,14 @@ where
206
200
Err ( e) => return Box :: new ( future:: err ( e. into ( ) ) ) ,
207
201
} ;
208
202
203
+ if self
204
+ . load_manager
205
+ . decline ( query. shape_hash , query. query_text . as_ref ( ) )
206
+ {
207
+ let err = SubscriptionError :: GraphQLError ( vec ! [ QueryExecutionError :: TooExpensive ] ) ;
208
+ return Box :: new ( future:: result ( Err ( err) ) ) ;
209
+ }
210
+
209
211
let result = execute_prepared_subscription (
210
212
query,
211
213
SubscriptionExecutionOptions {
0 commit comments