@@ -12,7 +12,7 @@ use selection::Selection;
1212use std:: collections:: { BTreeMap , BTreeSet } ;
1313use unions:: GqlUnion ;
1414
15- pub const DEFAULT_SCALARS : & [ & ' static str ] = & [ "ID" , "String" , "Int" , "Float" , "Boolean" ] ;
15+ pub const DEFAULT_SCALARS : & [ & str ] = & [ "ID" , "String" , "Int" , "Float" , "Boolean" ] ;
1616
1717#[ derive( Debug , PartialEq ) ]
1818pub struct Schema {
@@ -147,8 +147,8 @@ impl Schema {
147147 let response_data_fields = context
148148 . query_root
149149 . as_ref ( )
150- . or ( context. mutation_root . as_ref ( ) )
151- . or ( context. _subscription_root . as_ref ( ) )
150+ . or_else ( || context. mutation_root . as_ref ( ) )
151+ . or_else ( || context. _subscription_root . as_ref ( ) )
152152 . expect ( "no selection defined" ) ;
153153
154154 // TODO: do something smarter here
@@ -192,14 +192,21 @@ impl Schema {
192192 } )
193193 }
194194
195- pub fn ingest_interface_implementations ( & mut self , impls : BTreeMap < String , Vec < String > > ) {
196- impls. into_iter ( ) . for_each ( |( iface_name, implementors) | {
197- let iface = self
198- . interfaces
199- . get_mut ( & iface_name)
200- . expect ( & format ! ( "interface not found: {}" , iface_name) ) ;
201- iface. implemented_by = implementors. into_iter ( ) . collect ( ) ;
202- } ) ;
195+ pub fn ingest_interface_implementations (
196+ & mut self ,
197+ impls : BTreeMap < String , Vec < String > > ,
198+ ) -> Result < ( ) , failure:: Error > {
199+ impls
200+ . into_iter ( )
201+ . map ( |( iface_name, implementors) | {
202+ let iface = self
203+ . interfaces
204+ . get_mut ( & iface_name)
205+ . ok_or_else ( || format_err ! ( "interface not found: {}" , iface_name) ) ?;
206+ iface. implemented_by = implementors. into_iter ( ) . collect ( ) ;
207+ Ok ( ( ) )
208+ } )
209+ . collect ( )
203210 }
204211}
205212
@@ -215,7 +222,7 @@ impl ::std::convert::From<graphql_parser::schema::Document> for Schema {
215222 match definition {
216223 schema:: Definition :: TypeDefinition ( ty_definition) => match ty_definition {
217224 schema:: TypeDefinition :: Object ( obj) => {
218- for implementing in obj. implements_interfaces . iter ( ) {
225+ for implementing in & obj. implements_interfaces {
219226 let name = & obj. name ;
220227 interface_implementations
221228 . entry ( implementing. to_string ( ) )
@@ -269,7 +276,9 @@ impl ::std::convert::From<graphql_parser::schema::Document> for Schema {
269276 }
270277 }
271278
272- schema. ingest_interface_implementations ( interface_implementations) ;
279+ schema
280+ . ingest_interface_implementations ( interface_implementations)
281+ . expect ( "schema ingestion" ) ;
273282
274283 schema
275284 }
@@ -372,7 +381,9 @@ impl ::std::convert::From<::introspection_response::IntrospectionResponse> for S
372381 }
373382 }
374383
375- schema. ingest_interface_implementations ( interface_implementations) ;
384+ schema
385+ . ingest_interface_implementations ( interface_implementations)
386+ . expect ( "schema ingestion" ) ;
376387
377388 schema
378389 }
0 commit comments