@@ -12,7 +12,7 @@ use selection::Selection;
12
12
use std:: collections:: { BTreeMap , BTreeSet } ;
13
13
use unions:: GqlUnion ;
14
14
15
- pub const DEFAULT_SCALARS : & [ & ' static str ] = & [ "ID" , "String" , "Int" , "Float" , "Boolean" ] ;
15
+ pub const DEFAULT_SCALARS : & [ & str ] = & [ "ID" , "String" , "Int" , "Float" , "Boolean" ] ;
16
16
17
17
#[ derive( Debug , PartialEq ) ]
18
18
pub struct Schema {
@@ -147,8 +147,8 @@ impl Schema {
147
147
let response_data_fields = context
148
148
. query_root
149
149
. 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 ( ) )
152
152
. expect ( "no selection defined" ) ;
153
153
154
154
// TODO: do something smarter here
@@ -192,14 +192,21 @@ impl Schema {
192
192
} )
193
193
}
194
194
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 ( )
203
210
}
204
211
}
205
212
@@ -215,7 +222,7 @@ impl ::std::convert::From<graphql_parser::schema::Document> for Schema {
215
222
match definition {
216
223
schema:: Definition :: TypeDefinition ( ty_definition) => match ty_definition {
217
224
schema:: TypeDefinition :: Object ( obj) => {
218
- for implementing in obj. implements_interfaces . iter ( ) {
225
+ for implementing in & obj. implements_interfaces {
219
226
let name = & obj. name ;
220
227
interface_implementations
221
228
. entry ( implementing. to_string ( ) )
@@ -269,7 +276,9 @@ impl ::std::convert::From<graphql_parser::schema::Document> for Schema {
269
276
}
270
277
}
271
278
272
- schema. ingest_interface_implementations ( interface_implementations) ;
279
+ schema
280
+ . ingest_interface_implementations ( interface_implementations)
281
+ . expect ( "schema ingestion" ) ;
273
282
274
283
schema
275
284
}
@@ -372,7 +381,9 @@ impl ::std::convert::From<::introspection_response::IntrospectionResponse> for S
372
381
}
373
382
}
374
383
375
- schema. ingest_interface_implementations ( interface_implementations) ;
384
+ schema
385
+ . ingest_interface_implementations ( interface_implementations)
386
+ . expect ( "schema ingestion" ) ;
376
387
377
388
schema
378
389
}
0 commit comments