@@ -133,7 +133,10 @@ impl __Schema {
133133 column_names = & fkey. referenced_table_meta . column_names ;
134134 }
135135
136- let table: & Arc < Table > = self . context . get_table_by_oid ( table_ref. oid ) . unwrap ( ) ;
136+ let table: & Arc < Table > = self
137+ . context
138+ . get_table_by_oid ( table_ref. oid )
139+ . expect ( "failed to get table by oid" ) ;
137140
138141 let is_inflection_on = self . inflect_names ( table. schema_oid ) ;
139142
@@ -1123,6 +1126,15 @@ pub struct FilterTypeType {
11231126 pub schema : Arc < __Schema > ,
11241127}
11251128
1129+ impl FilterTypeType {
1130+ fn entity_name ( & self ) -> String {
1131+ match & self . entity {
1132+ FilterableType :: Scalar ( s) => s. name ( ) . expect ( "scalar name should exist" ) ,
1133+ FilterableType :: Enum ( e) => e. name ( ) . expect ( "enum type name should exist" ) ,
1134+ }
1135+ }
1136+ }
1137+
11261138#[ derive( Clone , Debug , Eq , PartialEq , Hash ) ]
11271139pub struct FilterEntityType {
11281140 pub table : Arc < Table > ,
@@ -1340,7 +1352,11 @@ fn function_args(schema: &Arc<__Schema>, func: &Arc<Function>) -> Vec<__InputVal
13401352 if matches ! ( t. category, TypeCategory :: Pseudo ) {
13411353 None
13421354 } else {
1343- Some ( ( t, arg_name. unwrap ( ) , arg_default) )
1355+ Some ( (
1356+ t,
1357+ arg_name. expect ( "function arg name should exist" ) ,
1358+ arg_default,
1359+ ) )
13441360 }
13451361 }
13461362 None => None ,
@@ -1713,7 +1729,7 @@ impl ___Type for NodeInterfaceType {
17131729 }
17141730
17151731 fn possible_types ( & self ) -> Option < Vec < __Type > > {
1716- let node_interface_name = self . name ( ) . unwrap ( ) ;
1732+ let node_interface_name = self . name ( ) . expect ( "node interface type name should exist" ) ;
17171733
17181734 let mut possible_types = vec ! [ ] ;
17191735
@@ -1723,8 +1739,10 @@ impl ___Type for NodeInterfaceType {
17231739 . sorted_by ( |a, b| a. name ( ) . cmp ( & b. name ( ) ) )
17241740 {
17251741 let type_interfaces: Vec < __Type > = type_. interfaces ( ) . unwrap_or ( vec ! [ ] ) ;
1726- let interface_names: Vec < String > =
1727- type_interfaces. iter ( ) . map ( |x| x. name ( ) . unwrap ( ) ) . collect ( ) ;
1742+ let interface_names: Vec < String > = type_interfaces
1743+ . iter ( )
1744+ . map ( |x| x. name ( ) . expect ( "type interface name should exist" ) )
1745+ . collect ( ) ;
17281746 if interface_names. contains ( & node_interface_name) {
17291747 possible_types. push ( type_)
17301748 }
@@ -2076,7 +2094,7 @@ impl ___Type for NodeType {
20762094 if foreign_table. is_none ( ) {
20772095 continue ;
20782096 }
2079- let foreign_table = foreign_table. unwrap ( ) ;
2097+ let foreign_table = foreign_table. expect ( "foreign table should exist" ) ;
20802098 if !self
20812099 . schema
20822100 . graphql_table_select_types_are_valid ( foreign_table)
@@ -2125,7 +2143,7 @@ impl ___Type for NodeType {
21252143 if foreign_table. is_none ( ) {
21262144 continue ;
21272145 }
2128- let foreign_table = foreign_table. unwrap ( ) ;
2146+ let foreign_table = foreign_table. expect ( "foreign table should exist" ) ;
21292147 if !self
21302148 . schema
21312149 . graphql_table_select_types_are_valid ( foreign_table)
@@ -3354,10 +3372,7 @@ impl ___Type for FilterTypeType {
33543372 }
33553373
33563374 fn name ( & self ) -> Option < String > {
3357- match & self . entity {
3358- FilterableType :: Scalar ( s) => Some ( format ! ( "{}Filter" , s. name( ) . unwrap( ) ) ) ,
3359- FilterableType :: Enum ( e) => Some ( format ! ( "{}Filter" , e. name( ) . unwrap( ) ) ) ,
3360- }
3375+ Some ( format ! ( "{}Filter" , self . entity_name( ) ) )
33613376 }
33623377
33633378 fn fields ( & self , _include_deprecated : bool ) -> Option < Vec < __Field > > {
@@ -3367,10 +3382,7 @@ impl ___Type for FilterTypeType {
33673382 fn description ( & self ) -> Option < String > {
33683383 Some ( format ! (
33693384 "Boolean expression comparing fields on type \" {}\" " ,
3370- match & self . entity {
3371- FilterableType :: Scalar ( s) => s. name( ) . unwrap( ) ,
3372- FilterableType :: Enum ( e) => e. name( ) . unwrap( ) ,
3373- }
3385+ self . entity_name( )
33743386 ) )
33753387 }
33763388
@@ -3853,15 +3865,15 @@ pub struct __Schema {
38533865#[ cached(
38543866 type = "SizedCache<String, HashMap<String, __Type>>" ,
38553867 create = "{ SizedCache::with_size(200) }" ,
3856- convert = r#"{ serde_json::ser::to_string(&schema.context.config).unwrap( ) }"# ,
3868+ convert = r#"{ serde_json::ser::to_string(&schema.context.config).expect("schema config should be a string" ) }"# ,
38573869 sync_writes = true
38583870) ]
38593871pub fn type_map ( schema : & __Schema ) -> HashMap < String , __Type > {
38603872 let tmap: HashMap < String , __Type > = schema
38613873 . types ( )
38623874 . into_iter ( )
38633875 . filter ( |x| x. name ( ) . is_some ( ) )
3864- . map ( |x| ( x. name ( ) . unwrap ( ) , x) )
3876+ . map ( |x| ( x. name ( ) . expect ( "type should have a name" ) , x) )
38653877 . collect ( ) ;
38663878 tmap
38673879}
0 commit comments