@@ -6,7 +6,7 @@ mod tests;
66
77use crate :: query:: UsedTypes ;
88use crate :: type_qualifiers:: GraphqlTypeQualifier ;
9- use std:: collections:: { HashMap , HashSet } ;
9+ use std:: collections:: { BTreeMap , BTreeSet } ;
1010
1111pub ( crate ) const DEFAULT_SCALARS : & [ & str ] = & [ "ID" , "String" , "Int" , "Float" , "Boolean" ] ;
1212
@@ -44,25 +44,25 @@ pub(crate) enum StoredFieldParent {
4444 Interface ( InterfaceId ) ,
4545}
4646
47- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
47+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
4848pub ( crate ) struct ObjectId ( u32 ) ;
4949
5050#[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
5151pub ( crate ) struct ObjectFieldId ( usize ) ;
5252
53- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
53+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
5454pub ( crate ) struct InterfaceId ( usize ) ;
5555
56- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
56+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
5757pub ( crate ) struct ScalarId ( usize ) ;
5858
59- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
59+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
6060pub ( crate ) struct UnionId ( usize ) ;
6161
62- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
62+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
6363pub ( crate ) struct EnumId ( usize ) ;
6464
65- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
65+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
6666pub ( crate ) struct InputId ( u32 ) ;
6767
6868#[ derive( Debug , Clone , Copy , PartialEq ) ]
@@ -98,7 +98,7 @@ pub(crate) struct StoredScalar {
9898 pub ( crate ) name : String ,
9999}
100100
101- #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq ) ]
101+ #[ derive( Debug , Clone , Copy , PartialEq , Hash , Eq , PartialOrd , Ord ) ]
102102pub ( crate ) enum TypeId {
103103 Object ( ObjectId ) ,
104104 Scalar ( ScalarId ) ,
@@ -222,7 +222,7 @@ pub(crate) struct Schema {
222222 stored_scalars : Vec < StoredScalar > ,
223223 stored_enums : Vec < StoredEnum > ,
224224 stored_inputs : Vec < StoredInputType > ,
225- names : HashMap < String , TypeId > ,
225+ names : BTreeMap < String , TypeId > ,
226226
227227 pub ( crate ) query_type : Option < ObjectId > ,
228228 pub ( crate ) mutation_type : Option < ObjectId > ,
@@ -239,7 +239,7 @@ impl Schema {
239239 stored_scalars : Vec :: with_capacity ( DEFAULT_SCALARS . len ( ) ) ,
240240 stored_enums : Vec :: new ( ) ,
241241 stored_inputs : Vec :: new ( ) ,
242- names : HashMap :: new ( ) ,
242+ names : BTreeMap :: new ( ) ,
243243 query_type : None ,
244244 mutation_type : None ,
245245 subscription_type : None ,
@@ -404,7 +404,7 @@ impl StoredInputType {
404404 & ' a self ,
405405 input_id : InputId ,
406406 schema : & ' a Schema ,
407- visited_types : & mut HashSet < & ' a str > ,
407+ visited_types : & mut BTreeSet < & ' a str > ,
408408 ) -> bool {
409409 visited_types. insert ( & self . name ) ;
410410 // The input type is recursive if any of its members contains it, without indirection
@@ -440,7 +440,7 @@ impl StoredInputType {
440440
441441pub ( crate ) fn input_is_recursive_without_indirection ( input_id : InputId , schema : & Schema ) -> bool {
442442 let input = schema. get_input ( input_id) ;
443- let mut visited_types = HashSet :: < & str > :: new ( ) ;
443+ let mut visited_types = BTreeSet :: < & str > :: new ( ) ;
444444 input. contains_type_without_indirection ( input_id, schema, & mut visited_types)
445445}
446446impl < ' doc , T > std:: convert:: From < graphql_parser:: schema:: Document < ' doc , T > > for Schema
0 commit comments