@@ -18,7 +18,6 @@ use graph::data::schema::ApiSchema;
1818use graph:: prelude:: { info, o, q, r, s, BlockNumber , CheapClone , Logger , TryFromValue } ;
1919
2020use crate :: execution:: ast as a;
21- use crate :: introspection:: introspection_schema;
2221use crate :: query:: { ast as qast, ext:: BlockConstraint } ;
2322use crate :: schema:: ast as sast;
2423use crate :: {
@@ -135,7 +134,6 @@ pub struct Query {
135134 pub query_text : Arc < String > ,
136135 pub variables_text : Arc < String > ,
137136 pub query_id : String ,
138- pub ( crate ) complexity : u64 ,
139137}
140138
141139impl Query {
@@ -220,9 +218,11 @@ impl Query {
220218 fragments,
221219 } ;
222220
223- // It's important to check complexity first, so `validate_fields` doesn't risk a stack
224- // overflow from invalid queries.
225- let complexity = raw_query. check_complexity ( max_complexity, max_depth) ?;
221+ // It's important to check complexity first, so `validate_fields`
222+ // doesn't risk a stack overflow from invalid queries. We don't
223+ // really care about the resulting complexity, only that all the
224+ // checks that `check_complexity` performs pass successfully
225+ let _ = raw_query. check_complexity ( max_complexity, max_depth) ?;
226226 raw_query. validate_fields ( ) ?;
227227 let ( selection_set, fragments) = raw_query. expand_variables ( ) ?;
228228
@@ -238,7 +238,6 @@ impl Query {
238238 query_text : query. query_text . cheap_clone ( ) ,
239239 variables_text : query. variables_text . cheap_clone ( ) ,
240240 query_id,
241- complexity,
242241 } ;
243242
244243 Ok ( Arc :: new ( query) )
@@ -311,26 +310,6 @@ impl Query {
311310 }
312311 }
313312
314- /// Return this query, but use the introspection schema as its schema
315- pub fn as_introspection_query ( & self ) -> Arc < Self > {
316- let introspection_schema = introspection_schema ( self . schema . id ( ) . clone ( ) ) ;
317-
318- Arc :: new ( Self {
319- schema : Arc :: new ( introspection_schema) ,
320- fragments : self . fragments . clone ( ) ,
321- selection_set : self . selection_set . clone ( ) ,
322- shape_hash : self . shape_hash ,
323- kind : self . kind ,
324- network : self . network . clone ( ) ,
325- logger : self . logger . clone ( ) ,
326- start : self . start ,
327- query_text : self . query_text . clone ( ) ,
328- variables_text : self . variables_text . clone ( ) ,
329- query_id : self . query_id . clone ( ) ,
330- complexity : self . complexity ,
331- } )
332- }
333-
334313 /// Should only be called for fragments that exist in the query, and therefore have been
335314 /// validated to exist. Panics otherwise.
336315 pub fn get_fragment ( & self , name : & str ) -> & a:: FragmentDefinition {
0 commit comments