File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
graphql_client_codegen/src Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -69,20 +69,19 @@ pub(crate) fn response_for_query(
69
69
}
70
70
71
71
let response_data_fields = {
72
- let opt_root_name = operation. root_name ( & context. schema ) ;
73
- let root_name: & str = if let Some ( root_name) = opt_root_name {
74
- root_name
72
+ let root_name = operation. root_name ( & context. schema ) ;
73
+ let opt_definition = context
74
+ . schema
75
+ . objects
76
+ . get ( & root_name) ;
77
+ let definition = if let Some ( definition) = opt_definition {
78
+ definition
75
79
} else {
76
80
panic ! (
77
81
"operation type '{:?}' not in schema" ,
78
82
operation. operation_type
79
83
) ;
80
84
} ;
81
- let definition = context
82
- . schema
83
- . objects
84
- . get ( & root_name)
85
- . expect ( "schema declaration is invalid" ) ;
86
85
let prefix = & operation. name ;
87
86
let selection = & operation. selection ;
88
87
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ impl<'query> Operation<'query> {
26
26
pub ( crate ) fn root_name < ' schema > (
27
27
& self ,
28
28
schema : & ' schema :: schema:: Schema ,
29
- ) -> Option < & ' schema str > {
29
+ ) -> & ' schema str {
30
30
match self . operation_type {
31
- OperationType :: Query => schema. query_type ,
32
- OperationType :: Mutation => schema. mutation_type ,
33
- OperationType :: Subscription => schema. subscription_type ,
31
+ OperationType :: Query => schema. query_type . unwrap_or ( "Query" ) ,
32
+ OperationType :: Mutation => schema. mutation_type . unwrap_or ( "Mutation" ) ,
33
+ OperationType :: Subscription => schema. subscription_type . unwrap_or ( "Subscription" ) ,
34
34
}
35
35
}
36
36
You can’t perform that action at this time.
0 commit comments