File tree Expand file tree Collapse file tree 2 files changed +8
-15
lines changed
graphql_client_codegen/src Expand file tree Collapse file tree 2 files changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -69,20 +69,16 @@ pub(crate) fn response_for_query(
6969 }
7070
7171 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. schema . objects . get ( & root_name) ;
74+ let definition = if let Some ( definition) = opt_definition {
75+ definition
7576 } else {
7677 panic ! (
7778 "operation type '{:?}' not in schema" ,
7879 operation. operation_type
7980 ) ;
8081 } ;
81- let definition = context
82- . schema
83- . objects
84- . get ( & root_name)
85- . expect ( "schema declaration is invalid" ) ;
8682 let prefix = & operation. name ;
8783 let selection = & operation. selection ;
8884
Original file line number Diff line number Diff line change @@ -23,14 +23,11 @@ pub struct Operation<'query> {
2323}
2424
2525impl < ' query > Operation < ' query > {
26- pub ( crate ) fn root_name < ' schema > (
27- & self ,
28- schema : & ' schema :: schema:: Schema ,
29- ) -> Option < & ' schema str > {
26+ pub ( crate ) fn root_name < ' schema > ( & self , schema : & ' schema :: schema:: Schema ) -> & ' schema str {
3027 match self . operation_type {
31- OperationType :: Query => schema. query_type ,
32- OperationType :: Mutation => schema. mutation_type ,
33- OperationType :: Subscription => schema. subscription_type ,
28+ OperationType :: Query => schema. query_type . unwrap_or ( "Query" ) ,
29+ OperationType :: Mutation => schema. mutation_type . unwrap_or ( "Mutation" ) ,
30+ OperationType :: Subscription => schema. subscription_type . unwrap_or ( "Subscription" ) ,
3431 }
3532 }
3633
You can’t perform that action at this time.
0 commit comments