@@ -248,7 +248,7 @@ pub trait GraphQLType: Sized {
248
248
///
249
249
/// The default implementation panics.
250
250
#[ allow( unused_variables) ]
251
- fn resolve_into_type ( & self , type_name : & str , selection_set : Option < Vec < Selection > > , executor : & Executor < Self :: Context > ) -> ExecutionResult {
251
+ fn resolve_into_type ( & self , type_name : & str , selection_set : Option < & [ Selection ] > , executor : & Executor < Self :: Context > ) -> ExecutionResult {
252
252
if Self :: name ( ) . unwrap ( ) == type_name {
253
253
Ok ( self . resolve ( selection_set, executor) )
254
254
} else {
@@ -274,7 +274,7 @@ pub trait GraphQLType: Sized {
274
274
/// The default implementation uses `resolve_field` to resolve all fields,
275
275
/// including those through fragment expansion, for object types. For
276
276
/// non-object types, this method panics.
277
- fn resolve ( & self , selection_set : Option < Vec < Selection > > , executor : & Executor < Self :: Context > ) -> Value {
277
+ fn resolve ( & self , selection_set : Option < & [ Selection ] > , executor : & Executor < Self :: Context > ) -> Value {
278
278
if let Some ( selection_set) = selection_set {
279
279
let mut result = HashMap :: new ( ) ;
280
280
resolve_selection_set_into ( self , selection_set, executor, & mut result) ;
@@ -288,7 +288,7 @@ pub trait GraphQLType: Sized {
288
288
289
289
fn resolve_selection_set_into < T , CtxT > (
290
290
instance : & T ,
291
- selection_set : Vec < Selection > ,
291
+ selection_set : & [ Selection ] ,
292
292
executor : & Executor < CtxT > ,
293
293
result : & mut HashMap < String , Value > )
294
294
where T : GraphQLType < Context =CtxT >
@@ -299,11 +299,11 @@ fn resolve_selection_set_into<T, CtxT>(
299
299
300
300
for selection in selection_set {
301
301
match selection {
302
- Selection :: Field ( Spanning { item : f, start : start_pos, .. } ) => {
302
+ & Selection :: Field ( Spanning { item : ref f, start : ref start_pos, .. } ) => {
303
303
if is_excluded (
304
- & match f. directives {
305
- Some ( sel) => Some ( sel. iter ( ) . cloned ( ) . map ( |s| s. item ) . collect ( ) ) ,
306
- None => None ,
304
+ & match & f. directives {
305
+ & Some ( ref sel) => Some ( sel. iter ( ) . cloned ( ) . map ( |s| s. item ) . collect ( ) ) ,
306
+ & None => None ,
307
307
} ,
308
308
executor. variables ( ) ) {
309
309
continue ;
@@ -327,30 +327,30 @@ fn resolve_selection_set_into<T, CtxT>(
327
327
let mut sub_exec = executor. sub_executor (
328
328
Some ( response_name. clone ( ) ) ,
329
329
start_pos. clone ( ) ,
330
- f. selection_set ) ;
330
+ f. selection_set . as_ref ( ) . map ( |v| & v [ .. ] ) ) ;
331
331
332
332
let field_result = instance. resolve_field (
333
333
& f. name . item ,
334
334
& Arguments :: new (
335
- f. arguments . map ( |m|
336
- m. item . into_iter ( ) . map ( |( k, v) |
335
+ f. arguments . as_ref ( ) . map ( |m|
336
+ m. item . iter ( ) . cloned ( ) . map ( |( k, v) |
337
337
( k. item , v. item . into_const ( exec_vars) ) ) . collect ( ) ) ,
338
338
& meta_field. arguments ) ,
339
339
& mut sub_exec) ;
340
340
341
341
match field_result {
342
342
Ok ( v) => merge_key_into ( result, response_name. clone ( ) , v) ,
343
343
Err ( e) => {
344
- sub_exec. push_error ( e, start_pos) ;
344
+ sub_exec. push_error ( e, start_pos. clone ( ) ) ;
345
345
result. insert ( response_name. clone ( ) , Value :: null ( ) ) ;
346
346
}
347
347
}
348
348
} ,
349
- Selection :: FragmentSpread ( Spanning { item : spread, .. } ) => {
349
+ & Selection :: FragmentSpread ( Spanning { item : ref spread, .. } ) => {
350
350
if is_excluded (
351
- & match spread. directives {
352
- Some ( sel) => Some ( sel. iter ( ) . cloned ( ) . map ( |s| s. item ) . collect ( ) ) ,
353
- None => None ,
351
+ & match & spread. directives {
352
+ & Some ( ref sel) => Some ( sel. iter ( ) . cloned ( ) . map ( |s| s. item ) . collect ( ) ) ,
353
+ & None => None ,
354
354
} ,
355
355
executor. variables ( ) ) {
356
356
continue ;
@@ -360,13 +360,13 @@ fn resolve_selection_set_into<T, CtxT>(
360
360
. expect ( "Fragment could not be found" ) ;
361
361
362
362
resolve_selection_set_into (
363
- instance, fragment. selection_set . clone ( ) , executor, result) ;
363
+ instance, & fragment. selection_set [ .. ] , executor, result) ;
364
364
} ,
365
- Selection :: InlineFragment ( Spanning { item : fragment, start : start_pos, .. } ) => {
365
+ & Selection :: InlineFragment ( Spanning { item : ref fragment, start : ref start_pos, .. } ) => {
366
366
if is_excluded (
367
- & match fragment. directives {
368
- Some ( sel) => Some ( sel. iter ( ) . cloned ( ) . map ( |s| s. item ) . collect ( ) ) ,
369
- None => None
367
+ & match & fragment. directives {
368
+ & Some ( ref sel) => Some ( sel. iter ( ) . cloned ( ) . map ( |s| s. item ) . collect ( ) ) ,
369
+ & None => None
370
370
} ,
371
371
executor. variables ( ) ) {
372
372
continue ;
@@ -375,12 +375,12 @@ fn resolve_selection_set_into<T, CtxT>(
375
375
let mut sub_exec = executor. sub_executor (
376
376
None ,
377
377
start_pos. clone ( ) ,
378
- Some ( fragment. selection_set . clone ( ) ) ) ;
378
+ Some ( & fragment. selection_set [ .. ] ) ) ;
379
379
380
- if let Some ( type_condition) = fragment. type_condition {
380
+ if let & Some ( ref type_condition) = & fragment. type_condition {
381
381
let sub_result = instance. resolve_into_type (
382
382
& type_condition. item ,
383
- Some ( fragment. selection_set . clone ( ) ) ,
383
+ Some ( & fragment. selection_set [ .. ] ) ,
384
384
& mut sub_exec) ;
385
385
386
386
if let Ok ( Value :: Object ( mut hash_map) ) = sub_result {
@@ -389,13 +389,13 @@ fn resolve_selection_set_into<T, CtxT>(
389
389
}
390
390
}
391
391
else if let Err ( e) = sub_result {
392
- sub_exec. push_error ( e, start_pos) ;
392
+ sub_exec. push_error ( e, start_pos. clone ( ) ) ;
393
393
}
394
394
}
395
395
else {
396
396
resolve_selection_set_into (
397
397
instance,
398
- fragment. selection_set . clone ( ) ,
398
+ & fragment. selection_set [ .. ] ,
399
399
& mut sub_exec,
400
400
result) ;
401
401
}
0 commit comments