@@ -9,7 +9,6 @@ use lazy_static::lazy_static;
9
9
use stable_hash:: crypto:: SetHasher ;
10
10
use stable_hash:: prelude:: * ;
11
11
use stable_hash:: utils:: stable_hash;
12
- use std:: collections:: HashMap ;
13
12
use std:: time:: Instant ;
14
13
use std:: { borrow:: ToOwned , collections:: HashSet } ;
15
14
@@ -25,7 +24,6 @@ use crate::introspection::{
25
24
} ;
26
25
use crate :: prelude:: * ;
27
26
use crate :: schema:: ast as sast;
28
- use crate :: values:: coercion;
29
27
30
28
lazy_static ! {
31
29
// Comma separated subgraph ids to cache queries for.
@@ -554,19 +552,15 @@ fn execute_field(
554
552
field : & a:: Field ,
555
553
field_definition : & s:: Field ,
556
554
) -> Result < r:: Value , Vec < QueryExecutionError > > {
557
- coerce_argument_values ( & ctx. query . schema , object_type, field)
558
- . and_then ( |argument_values| {
559
- resolve_field_value (
560
- ctx,
561
- object_type,
562
- field_value,
563
- field,
564
- field_definition,
565
- & field_definition. field_type ,
566
- & argument_values,
567
- )
568
- } )
569
- . and_then ( |value| complete_value ( ctx, field, & field_definition. field_type , value) )
555
+ resolve_field_value (
556
+ ctx,
557
+ object_type,
558
+ field_value,
559
+ field,
560
+ field_definition,
561
+ & field_definition. field_type ,
562
+ )
563
+ . and_then ( |value| complete_value ( ctx, field, & field_definition. field_type , value) )
570
564
}
571
565
572
566
/// Resolves the value of a field.
@@ -577,7 +571,6 @@ fn resolve_field_value(
577
571
field : & a:: Field ,
578
572
field_definition : & s:: Field ,
579
573
field_type : & s:: Type ,
580
- argument_values : & HashMap < & str , r:: Value > ,
581
574
) -> Result < r:: Value , Vec < QueryExecutionError > > {
582
575
match field_type {
583
576
s:: Type :: NonNullType ( inner_type) => resolve_field_value (
@@ -587,7 +580,6 @@ fn resolve_field_value(
587
580
field,
588
581
field_definition,
589
582
inner_type. as_ref ( ) ,
590
- argument_values,
591
583
) ,
592
584
593
585
s:: Type :: NamedType ( ref name) => resolve_field_value_for_named_type (
@@ -597,7 +589,6 @@ fn resolve_field_value(
597
589
field,
598
590
field_definition,
599
591
name,
600
- argument_values,
601
592
) ,
602
593
603
594
s:: Type :: ListType ( inner_type) => resolve_field_value_for_list_type (
@@ -607,7 +598,6 @@ fn resolve_field_value(
607
598
field,
608
599
field_definition,
609
600
inner_type. as_ref ( ) ,
610
- argument_values,
611
601
) ,
612
602
}
613
603
}
@@ -620,7 +610,6 @@ fn resolve_field_value_for_named_type(
620
610
field : & a:: Field ,
621
611
field_definition : & s:: Field ,
622
612
type_name : & str ,
623
- argument_values : & HashMap < & str , r:: Value > ,
624
613
) -> Result < r:: Value , Vec < QueryExecutionError > > {
625
614
// Try to resolve the type name into the actual type
626
615
let named_type = ctx
@@ -631,13 +620,10 @@ fn resolve_field_value_for_named_type(
631
620
. ok_or_else ( || QueryExecutionError :: NamedTypeError ( type_name. to_string ( ) ) ) ?;
632
621
match named_type {
633
622
// Let the resolver decide how the field (with the given object type) is resolved
634
- s:: TypeDefinition :: Object ( t) => ctx. resolver . resolve_object (
635
- field_value,
636
- field,
637
- field_definition,
638
- t. into ( ) ,
639
- argument_values,
640
- ) ,
623
+ s:: TypeDefinition :: Object ( t) => {
624
+ ctx. resolver
625
+ . resolve_object ( field_value, field, field_definition, t. into ( ) )
626
+ }
641
627
642
628
// Let the resolver decide how values in the resolved object value
643
629
// map to values of GraphQL enums
@@ -647,16 +633,13 @@ fn resolve_field_value_for_named_type(
647
633
// map to values of GraphQL scalars
648
634
s:: TypeDefinition :: Scalar ( t) => {
649
635
ctx. resolver
650
- . resolve_scalar_value ( object_type, field, t, field_value, argument_values )
636
+ . resolve_scalar_value ( object_type, field, t, field_value)
651
637
}
652
638
653
- s:: TypeDefinition :: Interface ( i) => ctx. resolver . resolve_object (
654
- field_value,
655
- field,
656
- field_definition,
657
- i. into ( ) ,
658
- argument_values,
659
- ) ,
639
+ s:: TypeDefinition :: Interface ( i) => {
640
+ ctx. resolver
641
+ . resolve_object ( field_value, field, field_definition, i. into ( ) )
642
+ }
660
643
661
644
s:: TypeDefinition :: Union ( _) => Err ( QueryExecutionError :: Unimplemented ( "unions" . to_owned ( ) ) ) ,
662
645
@@ -673,7 +656,6 @@ fn resolve_field_value_for_list_type(
673
656
field : & a:: Field ,
674
657
field_definition : & s:: Field ,
675
658
inner_type : & s:: Type ,
676
- argument_values : & HashMap < & str , r:: Value > ,
677
659
) -> Result < r:: Value , Vec < QueryExecutionError > > {
678
660
match inner_type {
679
661
s:: Type :: NonNullType ( inner_type) => resolve_field_value_for_list_type (
@@ -683,7 +665,6 @@ fn resolve_field_value_for_list_type(
683
665
field,
684
666
field_definition,
685
667
inner_type,
686
- argument_values,
687
668
) ,
688
669
689
670
s:: Type :: NamedType ( ref type_name) => {
@@ -699,13 +680,7 @@ fn resolve_field_value_for_list_type(
699
680
// is resolved into a entities based on the (potential) parent object
700
681
s:: TypeDefinition :: Object ( t) => ctx
701
682
. resolver
702
- . resolve_objects (
703
- field_value,
704
- field,
705
- field_definition,
706
- t. into ( ) ,
707
- argument_values,
708
- )
683
+ . resolve_objects ( field_value, field, field_definition, t. into ( ) )
709
684
. map_err ( |e| vec ! [ e] ) ,
710
685
711
686
// Let the resolver decide how values in the resolved object value
@@ -722,13 +697,7 @@ fn resolve_field_value_for_list_type(
722
697
723
698
s:: TypeDefinition :: Interface ( t) => ctx
724
699
. resolver
725
- . resolve_objects (
726
- field_value,
727
- field,
728
- field_definition,
729
- t. into ( ) ,
730
- argument_values,
731
- )
700
+ . resolve_objects ( field_value, field, field_definition, t. into ( ) )
732
701
. map_err ( |e| vec ! [ e] ) ,
733
702
734
703
s:: TypeDefinition :: Union ( _) => Err ( vec ! [ QueryExecutionError :: Unimplemented (
@@ -892,42 +861,3 @@ fn resolve_abstract_type<'a>(
892
861
) ]
893
862
} )
894
863
}
895
-
896
- /// Coerces argument values into GraphQL values.
897
- pub fn coerce_argument_values < ' a > (
898
- schema : & ApiSchema ,
899
- ty : impl Into < ObjectOrInterface < ' a > > ,
900
- field : & a:: Field ,
901
- ) -> Result < HashMap < & ' a str , r:: Value > , Vec < QueryExecutionError > > {
902
- let mut coerced_values = HashMap :: new ( ) ;
903
- let mut errors = vec ! [ ] ;
904
-
905
- let resolver = |name : & str | schema. document ( ) . get_named_type ( name) ;
906
-
907
- for argument_def in sast:: get_argument_definitions ( ty, & field. name )
908
- . into_iter ( )
909
- . flatten ( )
910
- {
911
- let value = field. argument_value ( & argument_def. name ) . cloned ( ) ;
912
- match coercion:: coerce_input_value ( value, & argument_def, & resolver) {
913
- Ok ( Some ( value) ) => {
914
- if argument_def. name == "text" . to_string ( ) {
915
- coerced_values. insert (
916
- argument_def. name . as_str ( ) ,
917
- r:: Value :: Object ( Object :: from_iter ( vec ! [ ( field. name. clone( ) , value) ] ) ) ,
918
- ) ;
919
- } else {
920
- coerced_values. insert ( & argument_def. name , value) ;
921
- }
922
- }
923
- Ok ( None ) => { }
924
- Err ( e) => errors. push ( e) ,
925
- }
926
- }
927
-
928
- if errors. is_empty ( ) {
929
- Ok ( coerced_values)
930
- } else {
931
- Err ( errors)
932
- }
933
- }
0 commit comments