@@ -27,7 +27,8 @@ use graph::{
27
27
use crate :: execution:: { ast as a, ExecutionContext , Resolver } ;
28
28
use crate :: runner:: ResultSizeMetrics ;
29
29
use crate :: schema:: ast as sast;
30
- use crate :: store:: { build_query, StoreResolver } ;
30
+ use crate :: store:: query:: build_query;
31
+ use crate :: store:: StoreResolver ;
31
32
32
33
lazy_static ! {
33
34
static ref ARG_FIRST : String = String :: from( "first" ) ;
@@ -54,42 +55,6 @@ type GroupedFieldSet<'a> = IndexMap<&'a str, CollectedResponseKey<'a>>;
54
55
/// attributes.
55
56
type ComplementaryFields < ' a > = BTreeMap < ObjectOrInterface < ' a > , String > ;
56
57
57
- /// An `ObjectType` with `Hash` and `Eq` derived from the name.
58
- #[ derive( Clone , Debug ) ]
59
- pub struct ObjectCondition < ' a > ( & ' a s:: ObjectType ) ;
60
-
61
- impl < ' a > Ord for ObjectCondition < ' a > {
62
- fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
63
- self . 0 . name . cmp ( & other. 0 . name )
64
- }
65
- }
66
-
67
- impl < ' a > PartialOrd for ObjectCondition < ' a > {
68
- fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
69
- Some ( self . 0 . name . cmp ( & other. 0 . name ) )
70
- }
71
- }
72
-
73
- impl std:: hash:: Hash for ObjectCondition < ' _ > {
74
- fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
75
- self . 0 . name . hash ( state)
76
- }
77
- }
78
-
79
- impl PartialEq for ObjectCondition < ' _ > {
80
- fn eq ( & self , other : & Self ) -> bool {
81
- self . 0 . name . eq ( & other. 0 . name )
82
- }
83
- }
84
-
85
- impl Eq for ObjectCondition < ' _ > { }
86
-
87
- impl < ' a > From < & ' a s:: ObjectType > for ObjectCondition < ' a > {
88
- fn from ( object : & ' a s:: ObjectType ) -> Self {
89
- ObjectCondition ( object)
90
- }
91
- }
92
-
93
58
/// Intermediate data structure to hold the results of prefetching entities
94
59
/// and their nested associations. For each association of `entity`, `children`
95
60
/// has an entry mapping the response key to the list of nodes.
@@ -717,7 +682,7 @@ fn execute_selection_set<'a>(
717
682
struct CollectedResponseKey < ' a > {
718
683
iface_cond : Option < & ' a s:: InterfaceType > ,
719
684
iface_fields : Vec < & ' a a:: Field > ,
720
- obj_types : IndexMap < ObjectCondition < ' a > , Vec < & ' a a:: Field > > ,
685
+ obj_types : IndexMap < sast :: ObjectCondition < ' a > , Vec < & ' a a:: Field > > ,
721
686
collected_column_names : CollectedAttributeNames < ' a > ,
722
687
}
723
688
@@ -745,10 +710,7 @@ impl<'a> CollectedResponseKey<'a> {
745
710
self . iface_fields . push ( field) ;
746
711
}
747
712
ObjectOrInterface :: Object ( o) => {
748
- self . obj_types
749
- . entry ( ObjectCondition ( o) )
750
- . or_default ( )
751
- . push ( field) ;
713
+ self . obj_types . entry ( o. into ( ) ) . or_default ( ) . push ( field) ;
752
714
}
753
715
}
754
716
}
@@ -776,11 +738,7 @@ impl<'a> IntoIterator for CollectedResponseKey<'a> {
776
738
self . iface_cond
777
739
. map ( |cond| ( ObjectOrInterface :: Interface ( cond) , iface_fields) )
778
740
. into_iter ( )
779
- . chain (
780
- self . obj_types
781
- . into_iter ( )
782
- . map ( |( c, f) | ( ObjectOrInterface :: Object ( c. 0 ) , f) ) ,
783
- ) ,
741
+ . chain ( self . obj_types . into_iter ( ) . map ( |( c, f) | ( c. into ( ) , f) ) ) ,
784
742
)
785
743
}
786
744
}
@@ -1057,7 +1015,7 @@ fn fetch(
1057
1015
1058
1016
/// Represents a finished column collection operation, mapping each object type to the final set of
1059
1017
/// selected SQL columns.
1060
- type AttributeNamesByObjectType < ' a > = BTreeMap < ObjectCondition < ' a > , AttributeNames > ;
1018
+ type AttributeNamesByObjectType < ' a > = BTreeMap < sast :: ObjectCondition < ' a > , AttributeNames > ;
1061
1019
1062
1020
#[ derive( Debug , Default , Clone ) ]
1063
1021
struct CollectedAttributeNames < ' a > ( HashMap < ObjectOrInterface < ' a > , AttributeNames > ) ;
@@ -1110,12 +1068,12 @@ impl<'a> CollectedAttributeNames<'a> {
1110
1068
1111
1069
/// Helper function for handling insertion on the `AttributeNamesByObjectType` struct.
1112
1070
fn upsert (
1113
- map : & mut BTreeMap < ObjectCondition < ' a > , AttributeNames > ,
1071
+ map : & mut BTreeMap < sast :: ObjectCondition < ' a > , AttributeNames > ,
1114
1072
object : & ' a s:: ObjectType ,
1115
1073
column_names : AttributeNames ,
1116
1074
) {
1117
1075
use std:: collections:: btree_map:: Entry ;
1118
- let key = ObjectCondition ( object) ;
1076
+ let key = object. into ( ) ;
1119
1077
let column_names = filter_derived_fields ( column_names, object) ;
1120
1078
match map. entry ( key) {
1121
1079
Entry :: Occupied ( mut entry) => {
0 commit comments