@@ -48,67 +48,73 @@ impl Schema {
48
48
for definition in query. definitions {
49
49
match definition {
50
50
query:: Definition :: Operation ( query:: OperationDefinition :: Query ( q) ) => {
51
- let definition = context
52
- . schema
53
- . query_type
54
- . clone ( )
55
- . and_then ( |query_type| context. schema . objects . get ( & query_type) )
56
- . expect ( "query type is defined" ) ;
57
- let prefix = & q. name . expect ( "unnamed operation" ) ;
58
- let prefix = format ! ( "RUST_{}" , prefix) ;
59
- definitions. extend ( definition. field_impls_for_selection (
60
- & context,
61
- & q. selection_set ,
62
- & prefix,
63
- ) ?) ;
64
- context. query_root = Some ( definition. response_fields_for_selection (
65
- & context,
66
- & q. selection_set ,
67
- & prefix,
68
- ) ) ;
51
+ context. query_root = {
52
+ let definition = context
53
+ . schema
54
+ . query_type
55
+ . clone ( )
56
+ . and_then ( |query_type| context. schema . objects . get ( & query_type) )
57
+ . expect ( "query type is defined" ) ;
58
+ let prefix = & q. name . expect ( "unnamed operation" ) ;
59
+ let prefix = format ! ( "RUST_{}" , prefix) ;
60
+ definitions. extend ( definition. field_impls_for_selection (
61
+ & context,
62
+ & q. selection_set ,
63
+ & prefix,
64
+ ) ?) ;
65
+ Some ( definition. response_fields_for_selection (
66
+ & context,
67
+ & q. selection_set ,
68
+ & prefix,
69
+ ) )
70
+ } ;
69
71
}
70
72
query:: Definition :: Operation ( query:: OperationDefinition :: Mutation ( q) ) => {
71
- let definition = context
72
- . schema
73
- . mutation_type
74
- . clone ( )
75
- . and_then ( |mutation_type| context. schema . objects . get ( & mutation_type) )
76
- . expect ( "mutation type is defined" ) ;
77
- let prefix = & q. name . expect ( "unnamed operation" ) ;
78
- let prefix = format ! ( "RUST_{}" , prefix) ;
73
+ context. mutation_root = {
74
+ let definition = context
75
+ . schema
76
+ . mutation_type
77
+ . clone ( )
78
+ . and_then ( |mutation_type| context. schema . objects . get ( & mutation_type) )
79
+ . expect ( "mutation type is defined" ) ;
80
+ let prefix = & q. name . expect ( "unnamed operation" ) ;
81
+ let prefix = format ! ( "RUST_{}" , prefix) ;
79
82
80
- definitions. extend ( definition. field_impls_for_selection (
81
- & context,
82
- & q. selection_set ,
83
- & prefix,
84
- ) ?) ;
85
- context. mutation_root = Some ( definition. response_fields_for_selection (
86
- & context,
87
- & q. selection_set ,
88
- & prefix,
89
- ) ) ;
83
+ definitions. extend ( definition. field_impls_for_selection (
84
+ & context,
85
+ & q. selection_set ,
86
+ & prefix,
87
+ ) ?) ;
88
+ Some ( definition. response_fields_for_selection (
89
+ & context,
90
+ & q. selection_set ,
91
+ & prefix,
92
+ ) )
93
+ } ;
90
94
}
91
95
query:: Definition :: Operation ( query:: OperationDefinition :: Subscription ( q) ) => {
92
- let definition = context
93
- . schema
94
- . subscription_type
95
- . clone ( )
96
- . and_then ( |subscription_type| {
97
- context. schema . objects . get ( & subscription_type)
98
- } )
99
- . expect ( "subscription type is defined" ) ;
100
- let prefix = & q. name . expect ( "unnamed operation" ) ;
101
- let prefix = format ! ( "RUST_{}" , prefix) ;
102
- definitions. extend ( definition. field_impls_for_selection (
103
- & context,
104
- & q. selection_set ,
105
- & prefix,
106
- ) ?) ;
107
- context. _subscription_root = Some ( definition. response_fields_for_selection (
108
- & context,
109
- & q. selection_set ,
110
- & prefix,
111
- ) ) ;
96
+ context. _subscription_root = {
97
+ let definition = context
98
+ . schema
99
+ . subscription_type
100
+ . clone ( )
101
+ . and_then ( |subscription_type| {
102
+ context. schema . objects . get ( & subscription_type)
103
+ } )
104
+ . expect ( "subscription type is defined" ) ;
105
+ let prefix = & q. name . expect ( "unnamed operation" ) ;
106
+ let prefix = format ! ( "RUST_{}" , prefix) ;
107
+ definitions. extend ( definition. field_impls_for_selection (
108
+ & context,
109
+ & q. selection_set ,
110
+ & prefix,
111
+ ) ?) ;
112
+ Some ( definition. response_fields_for_selection (
113
+ & context,
114
+ & q. selection_set ,
115
+ & prefix,
116
+ ) )
117
+ } ;
112
118
}
113
119
query:: Definition :: Operation ( query:: OperationDefinition :: SelectionSet ( _) ) => {
114
120
unimplemented ! ( )
@@ -292,7 +298,11 @@ impl ::std::convert::From<::introspection_response::IntrospectionResponse> for S
292
298
. insert ( name. clone ( ) , GqlEnum { name, variants } ) ;
293
299
}
294
300
Some ( __TypeKind:: SCALAR ) => {
295
- if DEFAULT_SCALARS . iter ( ) . find ( |s| s == & & name. as_str ( ) ) . is_none ( ) {
301
+ if DEFAULT_SCALARS
302
+ . iter ( )
303
+ . find ( |s| s == & & name. as_str ( ) )
304
+ . is_none ( )
305
+ {
296
306
schema. scalars . insert ( name) ;
297
307
}
298
308
}
0 commit comments